Hello,
I'm using NSFetchedResultsController and I have a problem to query count in parent attribute.
Assuming that following data model, 'Group', 'Category', 'Item'.
- Item : All items belong to ‘Category’
- Category : ‘Category’ may belong to a certain ‘Group’
- Group : 'Group' has zero to N 'Category'
And I want to search all items which does not have any groups in category.
My codes are following :
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Item" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];
...
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"((category.groups.@count == 0) || category.categoryId == %@)", categoryId];
...
But, "category.groups.@count" does not work in here. (It works well out of NSFetchedRequest)
How can I solve this problem. Please help me;;
Thanks.