NSPredicate: filtering objects by day of NSDate property

Given a NSDate * startDate and endDate and a NSManagedObjectContext * moc: NSPredicate *predicate = [NSPredicate predicateWithFormat:@”(date >= %@) AND (date <= %@)”, startDate, endDate]; NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; [request setEntity:[NSEntityDescription entityForName:@”EntityName” inManagedObjectContext:moc]]; [request setPredicate:predicate]; NSError *error = nil; NSArray *results = [moc executeFetchRequest:request error:&error];

NSFetchedResultsController with relationship not updating

The NSFetchedResultsController is only designed to watch one entity at a time. Your setup, while it makes sense, it a bit beyond what the NSFetchedResultsController is currently capable of watching on its own. My recommendation would be to set up your own watcher. You can base it off the ZSContextWatcher I have set up on … Read more

Changing a managed object property doesn’t trigger NSFetchedResultsController to update the table view

OK, I will explain your problem, then I will let you judge whether it is a bug in FRC or not. If you think it is a bug, then you really should file a bug report with apple. Your fetch result controller predicate is like this: NSString *predicate = [NSString stringWithFormat: @”clockSet.isOpen == YES”]; which … Read more

NSFetchedResultsController with predicate ignores changes merged from different NSManagedObjectContext

Turns out main NSManagedObjectContext didn’ t event fire NSManagedObjectContextObjectsDidChangeNotification for updated objects because it is not done for faulted objects. Generic fix (or keep a track of object IDs that needs this treatment): NSManagedObjectContext *context = [self managedObjectContext]; for(NSManagedObject *object in [[notification userInfo] objectForKey:NSUpdatedObjectsKey]) { [[context objectWithID:[object objectID]] willAccessValueForKey:nil]; } [context mergeChangesFromContextDidSaveNotification:notification]; From NSManagedObject Class … Read more