NSPredicate with SUBQUERY does not work
I need to sort my fetch request with selected people, but it doesn't return anything
I tried this code with coredata objects comparing
NSPredicate *peoplePredicate = [NSPredicate predicateWithFormat:@"SUBQUERY(classPeople, $p, $p IN %@).@count == %d", self.selectedPeople, [self.selectedPeople count]];
and this with nsnumber iD comparing
NSPredicate *peoplePredicate = [NSPredicate predicateWithFormat:@"SUBQUERY(classPeople, $p, $p.iD IN %@).@count == %d", self.selectedPeopleiD, [self.selectedPeopleiD count]];
I have entity class, which has relationship people. And I have viewcontroller where I can select some people in list, after selecting people objects are adding to array self.selectedPeople, so I need to fetch all objects of Class entity, which has selected people
thanks in advance
Ok the problem was that I've set No Inverse to my relationship people in Class entity, after I changed it to value of people relationship-to class problem solved
the working code is:
NSPredicate *peoplePredicate = [NSPredicate predicateWithFormat:@"SUBQUERY(classPeople, $p, $p IN %@).@count == %d", self.selectedPeople, [self.selectedPeople count]];
thanks to all
那么,你的谓词应该如下所示:
NSPredicate *peoplePredicate = [NSPredicate predicateWithFormat:@"ANY classPeople IN %@", self.selectedPeople];
链接地址: http://www.djcxy.com/p/60636.html
上一篇: 如何强制UNIDIRECTIONAL与