Skip to content

Instantly share code, notes, and snippets.

@cgreening
Created September 17, 2013 12:55
Show Gist options
  • Save cgreening/6593953 to your computer and use it in GitHub Desktop.
Save cgreening/6593953 to your computer and use it in GitHub Desktop.
fetchRequest.entity = [RNPFeedListEntry entityInManagedObjectContext:self.managedObjectContext];
// this is the main predicate to get the feed entries that belong to the us
NSPredicate *ownerPredicate = [NSPredicate predicateWithFormat:@"%K == %@ AND %K.%K == %@",
RNPFeedListEntryRelationships.owner, self, RNPFeedListEntryRelationships.feed,
RNPFeedAttributes.action, @(FeedAction_LIKE), self];
// this is the predicate to check that we have the required item
NSPredicate *itemPopulatedPredicate = [NSPredicate predicateWithFormat:@"(%K.%K != nil AND %K.%K != nil) OR (%K.%K == nil)",
RNPFeedListEntryRelationships.feed, RNPFeedAttributes.itemId,
RNPFeedListEntryRelationships.feed, RNPFeedRelationships.item,
RNPFeedListEntryRelationships.feed, RNPFeedAttributes.itemId];
fetchRequest.predicate = [NSCompoundPredicate andPredicateWithSubpredicates:@[ownerPredicate, itemPopulatedPredicate]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment