Reputation: 91
I have table A and B. A and B have one to many relationship.I am fetching data from the A but while fetching data i get all the data of B in NSSet.But I Want to have some specific data of B in NSSet while i am fetching data from A.
Upvotes: 2
Views: 425
Reputation: 4805
You can apply predicate on NSSet. NSSet has instance method-
- (NSSet *)filteredSetUsingPredicate:(NSPredicate *)predicate
Example from apple documentation
NSSet *sourceSet =
[NSSet setWithObjects:@"One", @"Two", @"Three", @"Four", nil];
NSPredicate *predicate =
[NSPredicate predicateWithFormat:@"SELF beginswith 'T'"];
NSSet *filteredSet =
[sourceSet filteredSetUsingPredicate:predicate];
// filteredSet contains (Two, Three)
Upvotes: 2