Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple NSPredicate @"1 == 0" not filtering fetched results?
    primarykey
    data
    text
    <p>What is wrong with this code?</p> <p>I know this is a silly predicate. But it's just to show that if this was working, it should be filter everything out, right?</p> <p>Somehow, it's not. I'm getting every Month object in my DB, when I should be getting none.</p> <p>I guess this tells me that the problem might not be in the predicate?</p> <pre><code>NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Month" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; [fetchRequest setPredicate: [NSPredicate predicateWithFormat:@"1 == 0"]]; NSSortDescriptor *sortDescriptor1 = [[NSSortDescriptor alloc] initWithKey:@"month_" ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor1, nil]; [fetchRequest setSortDescriptors:sortDescriptors]; [fetchRequest setFetchBatchSize:20]; NSFetchedResultsController *theFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:@"month_" cacheName:@"Root"]; - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [[_fetchedResultsController sections] count]; } </code></pre> <p>What I actually wanted to do is,</p> <pre><code>[NSPredicate predicateWithFormat:@"year.year_ == %d", year] </code></pre> <p>And I also tried this,</p> <pre><code>[NSPredicate predicateWithFormat:@"month_ == %d", 1] </code></pre> <p>Just to see if it works. But nothing.</p> <p>edit:</p> <p>At this point, no matter what predicate I set, as long it's a valid, well formatted predicate. It doesn't complaint, and get's me all objects. It's just not filtering anything.</p> <p>I'm pretty much using boiler plate code from Apple's documentation.</p> <p>Can anyone help me figure this out?</p> <p>Thank you!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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