Load specific items from NSManagedObjectContext

Given the case you do not want to load all elements from the context but only those matching a certain criteria. For this, you need to use a NSPredicate.

NSPredicate *readArticlesPredicate = [NSPredicate predicateWithFormat:@"read == 1"];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

[fetchRequest setEntity: [NSEntityDescription entityForName:@"FeedEntry" inManagedObjectContext: self.managedObjectContext]];

[fetchRequest setPredicate:readArticlesPredicate];

NSError *error = nil;
NSArray *results = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];

if (error) {
    NSLog(@"Error: %@\n%@", [error localizedDescription], [error userInfo]);
    return nil;
return results;


The string you pass as argument for [NSPredicate predicateWithFormat:] can be a condition like you would use in a SQL query like:

@"views > 546"