Your saveMainContext
method should only be called from the main thread and should simply be implemented as:
- (BOOL)saveMainContext
{
NSError *error = nil;
if ([[[[CoreDataManager sharedInstance] objectStore] mainQueueManagedObjectContext] saveToPersistentStore:&error]) {
contextSaved = YES;
} else {
NSLog(@"Save error: %@", error);
}
return contextSaved;
}
Calling an instance of UIBarButtonItem
suggests that you have a memory management issue in that something which is observing the context save is not removing itself before it is deallocated. Check all of your observers.