background save cause fetch not working #210

Closed
caiguo37 opened this Issue Jul 16, 2012 · 4 comments

Comments

Projects
None yet
3 participants
@caiguo37
dispatch_async(retrieve_queue(), ^{
    ASIHTTPRequest *roomRequest = //code to genrate the request;
    [roomRequest startSynchronous];
    if (!roomRequest.error)
    {
        [MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
            // code to parse the data
        }];
    }
});

After the parse finish,every room will have at least on message. But the FRC just not return any result even if the is one message in that room and the status is > 0.

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(rid == %@) AND (status >= 0)", _room];
_fetchControllerForHistory = [Message MR_fetchAllSortedBy:@"serverDatetime,index" ascending:YES withPredicate:predicate groupBy:nil delegate:self];
NSLog(@"%i,%i",_room.mids.count, self.fetchControllerForHistory.fetchedObjects.count);
1,0

This only happen when BACKGROUND SAVE happened.

NSManagedObjectContext *localContext = [NSManagedObjectContext MR_contextForCurrentThread];
[localContext performBlockAndWait:^{
   // code to parse the data
    [localContext MR_save];
}];

If I do the parse like this,the FRC can return the right data,but the data is not saved persistently.

@caiguo37

This comment has been minimized.

Show comment Hide comment
@angeloh

This comment has been minimized.

Show comment Hide comment
@angeloh

angeloh Aug 10, 2012

I think this is due to the issue describes here. http://wbyoung.tumblr.com/post/27851725562/core-data-growing-pains

angeloh commented Aug 10, 2012

I think this is due to the issue describes here. http://wbyoung.tumblr.com/post/27851725562/core-data-growing-pains

@blackgold9

This comment has been minimized.

Show comment Hide comment
@blackgold9

blackgold9 Sep 7, 2012

Contributor

Working on a fix for this.

Contributor

blackgold9 commented Sep 7, 2012

Working on a fix for this.

@blackgold9 blackgold9 closed this Oct 9, 2012

@blackgold9

This comment has been minimized.

Show comment Hide comment
@blackgold9

blackgold9 Oct 9, 2012

Contributor

SHould be fixed now. Please re-open if not

Contributor

blackgold9 commented Oct 9, 2012

SHould be fixed now. Please re-open if not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment