Reputation: 31
For an NSObject class A that contains another NSObject class B variable as member, can we make use of NSPredicate to perform a search on an array containing objects of class A by using that member?
Thanks Arnieterm
Upvotes: 0
Views: 1197
Reputation: 2741
Sounds like you want to filter an existing array of objects of type A where their B member attribute, let's call it objectB, matches a particular value? So, first the predicate:
NSPredicate *predicate =
[NSPredicate predicateWithFormat:@"objectB == %@", aBInstance ];
And then just filter your source array using the predicate:
NSArray *filtered = [yourSourceArray filteredArrayUsingPredicate:predicate];
Upvotes: 2