Reputation: 1341
i'm using core data and in the function:
- (NSFetchedResultsController*)fetchedResultsController()
i want to use a predicate that can let the NSFetchRequest return the managed objects that has a given relationship value. i tried this:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"belongToS like[cd] %@", (S*)self.s];
[fetchRequest setPredicate:predicate];
Note:
- belongToS: relationship of type (S *)
- self.s is a managed object casted to type (S *) since it is of NSManagedObject and actually it's truly an object of type (S *).
when i run the code it doesn't return anything! how can i edit it to make it work? and is there any optimal solution for fetching objects that has the same relationship value?
Upvotes: 0
Views: 451
Reputation: 540045
LIKE
in a predicate is only for comparing strings. To fetch all objects that are related to self.s
, the following should work:
[NSPredicate predicateWithFormat:@"belongToS = %@", self.s];
Upvotes: 1