Search code examples
nspredicateone-to-manyany

NSPredicate: More AND condition after ANY is possible?


[NSPredicate predicateWithFormat:@"ANY (spaceVariableDomains.domain.name = %@ AND spaceVariableDomains.variable.val = %@)", ...];

I want to write something like above into NSPredicate, but it is unable to parse the format string. Is it possible somehow compound conditions after ANY? Do I need to use SUBQUERY?


Solution

  • Finally I used SUBQUERY approach, basically this expression helped me:

    SUBQUERY(spaceVariableDomains, $x, $x.domain.name = 'xxx' and $x.variable.val = 'yyy').@count > 0 AND SUBQUERY(spaceVariableDomains, $x, $x.domain.name = 'zzz' and $x.variable.val = 'www').@count > 0