I have created an NSManagedObject called TItem. To that object, I’ve added a helper instance method like the following:
- (BOOL) isItemForUser:(TUser *)user;
isItemForUser compares various properties in the TUser object to itself and returns a BOOL based on the results of the comparison.
I want to create a predicate that will be able to pass a TUser object to that method so that I can find all TItem objects that would return YES with a given object passed. In essence, I want to do something like the following:
fetchRequest.predicate = [NSPredicate predicateWithFormat:@"isItemForUser:%@ == YES",self.user];
The above syntax is obviously not correct, but I am looking for a something in the same spirit. Any ideas?
Thanks!
I would explore doing whatever comparisons done in your
isItemForUsermethod in the predicate instead. Perhaps simplifying your data model to make that comparison easier? For instance, adding some new attribute that maps to a user and is calculated when the object is created. That way, the comparison is very simple.