Skip to content

Instantly share code, notes, and snippets.

@EdSancha
Created March 9, 2015 22:34
Show Gist options
  • Save EdSancha/7472b86551018049a6b0 to your computer and use it in GitHub Desktop.
Save EdSancha/7472b86551018049a6b0 to your computer and use it in GitHub Desktop.
Listen to context changes and check whether an specific value has been changed
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contextChanged:) name:NSManagedObjectContextWillSaveNotification object:nil];
-(void)contextChanged:(NSNotification *)notification {
for(NSManagedObject *object in [(NSManagedObjectContext *)notification.object updatedObjects]) {
if([object isKindOfClass:[Product class]]) {
id value = [object changedValues][@"value"];
if (value){
NSLog(@"%@",object);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment