Search code examples
ioscore-datansmanagedobjectcontextmagicalrecord

MagicalRecord - no contextDidSaveNotification when using saveWithBlock


This works, but MR_contextForCurrentThread is deprecated:

//    context = [NSManagedObjectContext MR_contextForCurrentThread];
//    
//    [context MR_saveToPersistentStoreWithCompletion:^(BOOL success, NSError* error) {
//        
//    }];

When I use the below, I don't get any contextDidSaveNotification notifications:

[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {

    }];

I'm using version 2.3. Is this a bug or do I need to do something else to get the notifications?


Solution

  • This block is not setup to let you subscribe to change notifications. You should simply create a new context on your background thread and use your old save method:

    context = [NSManagedObjectContext MR_context];
    
    [context MR_saveToPersistentStoreWithCompletion:...];