I have three entities:
Entity A —– m:n —— Entity B —— m:1 —— Entity C
To get the set of B’s belonging to an A, I can use a.b. Since every B has only one C, I’d like to do something to Entity A to be able to say a.c to get the set of C’s. After reading the Apple docs for fetched properties (http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/CoreData/Articles/cdRelationships.html), and thumbing through some fetched property questions here, this doesn’t seem to be the right approach.
Can I use fetched properties to do this? Is there another way?
You can use
[a valueForKeyPath:@"b.c"]. This will hand back the value ofb.cfor everybina.b.More accurately, when an
NSArrayreceives a-valueForKey:call, it constructs a new array containing the results of forwarding that-valueForKey:on to every element in the array. This behavior carries over to-valueForKeyPath:as well. So since the keypathbis an array, the keypathb.cis an array of the keycfor every value in thebarray.