i have in my code like this :
- (id)init
{
self = [super initWithNibName:nibName bundle:nil];
if (self) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(userDataDidUpdate)
name:NSManagedObjectContextDidSaveNotification
object:[UserData managedObjectContext]];
}
return self;
}
- (void)userDataDidUpdate
{
// notification received...
}
and in an other class ( CoreData manager) i am doing like this :
[[UserData managedObjectContext] performBlock:^{
NSError *error;
if (![[UserData managedObjectContext] save:&error])
{
// handle error
}
isSyncing = NO;
[[NSNotificationCenter defaultCenter] postNotificationName:NDUserDataSyncDidUpdateLocalData object:nil];
}];
The problem is that i send the notification in the performBlock of the managed objectContext and it's not the main thread. How can i send the notification inside the performBlcok in the main thread ?
Thanks