I have a core data object A.
Object A contains an array of objects B – like A.bObjects.
Object B contains an array of objects C – like B.cObjects.
How can I get all objects B from object A where B.cObjects is nil?
I can work around this like:
NSMutableArray *array = [[NSMutableArray alloc] init];
for(B *b in A.bObjects)
{
if([b.cObjects count] == 0)
[array addObject:b];
}
But i think it will take a lot of resources if I would have a lot of objects B. And I do not like my workaround.:)
Any ideas?
I believe you could use, if you just want all the Bs from a particular A that have empty cObjects.
If you want all the Bs from all of the As that have empty cObjects, combine that with a NSFetchRequest.
Not a 100% sure which would be more effective, but if I were to hazard a guess, I would say use predicates and KVC as I believe Apple has made some optimisations under the hood. Also its fewer lines of code whi