我正在尝试使用 Cloudkit 使用复合谓词来执行此操作,但 Xcode 错误显示“意外表达式”。有人知道我的代码有什么问题吗?感谢任何帮助!
let userRef = CKReference(recordID: userID, action: .None)
let predicateOne = NSPredicate(format: "recordID IN %@ AND user = %@", postIDs, userRef)
// I need all user post's that match the IDs in the array and where the user ID matches the Id in the reference field for the user.
let predicateTwo = NSPredicate(format: "recordID IN %@", followIDs)
// Or I want recordID's that match the IDs in this array.
// I want records if either predicate condition is met, or both, which is why I'm using an OrPredicateType.
let predicate = NSCompoundPredicate(type: NSCompoundPredicateType.OrPredicateType, subpredicates: [predicateOne!, predicateTwo!])
let query = CKQuery(recordType: "UserPosts", predicate: predicate)
let queryOp = CKQueryOperation(query: query)