我想在 swift 3 中创建一个复杂的NSCompoundPredicate,但是,我不知道该怎么做。
假设我有 5 个谓词 (p1,p2,p3,p4,p5)。我想实现以下条件:
compound1 = (p1 AND p2 AND p3) // NSCompoundPredicate(type: .and,
//subpredicates: predicates)
compound2 = (p4 AND p5) // NSCompoundPredicate(type: .and,
//subpredicates: predicates)
compound3 = (compound1 OR compound2) // problem is here
fetchRequest.predicate = compound3
NSCompoundPredicate因为它的第二个参数得到它不想要的 NSPredicates 数组。什么是最好的解决方案?