I'm just starting out with Core Data and I need some help.
At the moment I fetch all of the objects in Core Data, instead of just the ones that have changed.
My controller listens out for NSNotifications from CoreData. I want to use the notification.userInfo dictionary to specify which objects need to be retrieved from Core Data.
How can I change the following method to make use of the dictionary? How do I set up a predicate?
At the moment I fetch all of the objects in Core Data, instead of just the ones that have changed.
My controller listens out for NSNotifications from CoreData. I want to use the notification.userInfo dictionary to specify which objects need to be retrieved from Core Data.
How can I change the following method to make use of the dictionary? How do I set up a predicate?
Code:
-(void)updateLocations:(NSDictionary*)dictionary
{
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Location" inManagedObjectContext:self.managedObjectContext];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:entity];
NSLog(@"fish: Dictionary: %@ :fish", dictionary);
NSError *error;
NSArray *foundObjects = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
if (foundObjects == nil) {
FATAL_CORE_DATA_ERROR(error);
return;
}
if (locations != nil) {
[self.mapView removeAnnotations:locations];
}
locations = foundObjects;
[self.mapView addAnnotations:locations];
}