0

Possible Duplicate:
NSFetchedResultsController with predicate ignores changes merged from different NSManagedObjectContext

I am using a NSFetchedResultsController to control the updating of a grid view I am using. I am setting up a compound predicate where there is a boolean property that I'm checking for NO and then ALSO checking to see if there are any of the relationship entity.

In a background thread, I use a separate MOC to save, and this works no problem. With the predicate only set to the selected part, my delegate methods get called. If I add the relationship part of the predicate, my delegate never gets called.

Is this a limitation of the NSFetchedResultsController? Can it not check children entities?

    NSSortDescriptor *sortDesc = [NSSortDescriptor sortDescriptorWithKey:@"order" ascending:YES];
    NSFetchRequest *req = [NSFetchRequest fetchRequestWithEntityName:@"Tab"];
    //Problematic line here.
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"(selected == NO) && (modules.@count > 0)"];
    [req setPredicate:pred];
    [req setSortDescriptors:@[sortDesc]];
    NSFetchedResultsController *fc = [[NSFetchedResultsController alloc] initWithFetchRequest:req managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:nil];
    [fc setDelegate:self];
Community
  • 1
  • 1
DavidAndroidDev
  • 2,371
  • 3
  • 25
  • 41
  • Something to add to this. If I do the update in the background, and the delegate doesn't get called. I can close the app, and then the initial load of the fetch controller shows the item in the grid! – DavidAndroidDev Oct 05 '12 at 15:07
  • And of course, I find the answer to this as soon as I post. Sigh. This fixed my problem. http://stackoverflow.com/questions/3923826/nsfetchedresultscontroller-with-predicate-ignores-changes-merged-from-different?rq=1 – DavidAndroidDev Oct 05 '12 at 15:12

0 Answers0