Note that there are some explanatory texts on larger screens.

plurals
  1. PONSPredicate - filtering values based on a BOOLEAN stored value
    text
    copied!<p>I have a core data model object called Entry. In this I have an attribute IsFavorite.</p> <p>I would like to use an NSPredicate to filter the results of my NSFetchedResultsController.</p> <p>Currently I am getting EXC_BAD_ACCESS when the fetch executes.</p> <pre><code>NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; // Edit the entity name as appropriate. NSEntityDescription *thisEntry = [NSEntityDescription entityForName:@"Entry" inManagedObjectContext:managedObjectContext_]; [fetchRequest setEntity:thisEntry]; NSPredicate *fetchPredicate = [NSPredicate predicateWithFormat:@"Entry.isFavorite == %@", [NSNumber numberWithBool: YES]]; [fetchRequest setPredicate:predicate]; NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:@"Root"]; aFetchedResultsController.delegate = self; NSError *error = nil; if (![aFetchedResultsController performFetch:&amp;error]) { NSlog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } </code></pre> <p>IF I remove the line that sets the predicate on the fetchRequest, my code executes perfectly.</p> <p>I am clearly n00bin out on the predicate but have had much trouble trying to find out how to perform operations on a BOOLEAN value from a core data model object. It is noted that there are answers on how to do this with a string or int value but I can't find a BOOLEAN example.</p> <p>Many thanks !</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload