jeudi 13 août 2015

Crash when try to save an object inside a block. (CoreData could not fulfill a fault for...)

I'm trying to save an object inside the AFNetworking block, but SOMETIMES it crashes with error: CoreData could not fulfill a fault for...

I've read that it's related when I try to manage an object data when it was deleted from the persistent store.

(http://ift.tt/1iEZzmg)

How can I avoid this?


Example:

Line *line = [Line MR_createEntity];
[line setSync:@(SYNC_PROCESSING)];

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"http://test.com/request" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

    // CRASH
    [line setSync:@(SYNC_SUCCESS)];
    [[NSManagedObjectContext MR_defaultContext] MR_saveToPersistentStoreAndWait];

} failure:nil];



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire