Master data matches many list relationships

In connection with this question , he appeared new:

Say that I have the following attributes: [red, green, blue] How can I get objects whose attributes are in the list , but only in this list ?

 * Object_1 (red, green, blue) * Object_2 (red, green) * Object_3 (red) 

This means that there is no fetch Object_4 (red, green, blue, yellow) , since it has yellow , which is not in the list

0
ios objective-c cocoa core-data
Jul 07 2018-12-12T00:
source share
1 answer

you can create a complex predicate that can add your predicates:

 NSPredicate *predOne = [NSPredicate predicateWithFormat:@"color == %@",@"red"]; NSPredicate *predTwo = [NSPredicate predicateWithFormat:@"color == %@",@"blue"]; NSPredicate *predThree = [NSPredicate predicateWithFormat:@"color == %@",@"green"]; NSArray *allPredicates = [[NSArray alloc] initWithObjects:predOne,predTwo,predThree, nil]; NSPredicate finalPredicate = [NSCompoundPredicate andPredicateWithSubpredicates:allPredicates]; 
0
Jul 07 '12 at 12:40
source share



All Articles