Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

background save cause fetch not working #210

Closed
caiguo37 opened this Issue · 4 comments

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.

@angeloh

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

@blackgold9
Collaborator

Working on a fix for this.

@blackgold9 blackgold9 closed this
@blackgold9
Collaborator

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
Something went wrong with that request. Please try again.