objective c - Core Data match a to many relationship to a list -


related this question, occured new 1 :

say have these attributes : [red, green, blue] how can fetch objects or attributes in list, but in list only ?

* object_1 (red, green, blue) * object_2 (red, green) * object_3 (red) 

this means not fetch object_4 (red, green, blue, yellow) because has yellow not in list

you can make compound predicate can add 3 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]; 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -