2
我想在swift 3中創建一個複雜的NSCompoundPredicate,但是,我不知道該怎麼做。在swift 3中創建複雜的NSCompoundPredicate 3
假設我有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的陣列,它不渴望。什麼是最好的解決方案?從NSPredicate