Create complicated NSCompoundPredicate in swift 3

╄→尐↘猪︶ㄣ 提交于 2019-12-02 00:39:58

NSCompoundPredicate inherits from NSPredicate, therefore you can pass the compound predicates creates in the first steps as subpredicate to another compound predicate:

let compound1 = NSCompoundPredicate(type: .and, subpredicates: [p1, p2, p3])
let compound2 = NSCompoundPredicate(type: .and, subpredicates: [p4, p5])
let compound3 = NSCompoundPredicate(type: .or, subpredicates: [compound1, compound2])

fetchRequest.predicate = compound3
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!