Reputation: 17169
In my NSFetchedResultsController
I want to have an NSPredicate
which only fetches objects with certain relationships.
For example:
I have three subclassed NSManagedObject
s: Flight
, Aircraft
, Battery
.
Every Flight
has one Aircraft
. Every Flight
can have several Battery
objects.
So when I am fetching the Flight
objects, this is something I have tried with the predicate: [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"aircraft = %@", aircraftObj]];
So I only want to fetch the Flight
objects which are related to that specific Aircraft
object. This doesn't work, but how can I do this?
Secondly, building on that, the Flight
has batteries
which is an NSSet of Battery
objects. So if I want to do the same as the Aircraft, but filter the Battery
objects, how would I do this?
Thanks, let me know if I need to explain further.
Upvotes: 1
Views: 668
Reputation: 6011
You have a problem of "double formatting" your predicate.
You could simply write:
[NSPredicate predicateWithFormat:@"aircraft = %@", aircraftObj]
the same would go for your Battery
objects (but with the proper Flight
)
Upvotes: 2