Use of OR operator on Cloudkit predicate

自古美人都是妖i 提交于 2019-12-02 00:32:10

Cloud Kit's CKQuery doesn't support OR in a predicate. See the documentation for CKQuery. It shows all the supported predicate operators and while AND and NOT are supported, OR is not.

One possible replacement for OR would be IN. I've only seen this where you wish to see if a single field contains one of several values. But your case is in reverse. Try the following but it may not work.

var userID = "0984093843897"
NSPredicate(format:"%@ IN { %K, %K, %K, %K } AND active = true", userID, "userID1", "userID2", "userID3", "userID4"]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!