Quick Explanation of SUBQUERY in NSPredicate Expression

前端 未结 3 1600
予麋鹿
予麋鹿 2020-11-27 18:03

There appears to be zero documentation about the SUBQUERY keyword from Apple and I can\'t find a simple explanation about it on SO or on Google. It\'s a conspiracy! ;)

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 18:34

    Subquery represents a predicate (third argument - $x IN %@) that is evaluated on all objects (second argument - $x - it's like a variable name in foreach) of a relationship (first argument - Bs). Similarly to regular query returns a list of objects.

    I see in many places that people use $x almost dogmatically, but $object in objects relationship makes perfect sense as well (or $city in cities...) :)

    I've written a blog post about SUBQUERY some time ago. You can check it here.

提交回复
热议问题