Created
March 9, 2015 22:34
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[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