You can keep it simple and use NSUserDefaults. You can add an observer to the notification NSManagedObjectContextWillSave. Then create / update the object NSDateusing the NSStringname Class. I have this in mine AppDelegate:
In the app: didFinishLaunchingWithOptions:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(mocWillSave:)
name:NSManagedObjectContextWillSaveNotification
object:self.managedObjectContext];
Selector
- (void)mocWillSave:(NSNotification*)note {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSArray *updatedObjectClasses = [self.managedObjectContext.updatedObjects valueForKeyPath:@"class"];
for (id obj in updatedObjectClasses) {
[userDefaults setObject:[NSDate date] forKey:obj];
}
[userDefaults synchronize];
}
NOTE: This, of course, applies only to the account updatedObjects. Of course you can do it for insertedObjects.
Corey source
share