Xcode抛出一个非常模棱两可的错误:
“ firesOnRecordCreation”的歧义使用
创建CKQuerySubscription时。实际上,它会对添加到该调用的每个选项执行此操作。那是编译器错误吗?解决方案?
let predicate = NSPredicate(value: true)
let subscriptionID = "notes-changed"
let noteSubscription = CKQuerySubscription(recordType: "Notes",
predicate: predicate,
subscriptionID: subscriptionID,
options: [.firesOnRecordCreation,
.firesOnRecordDeletion,
.firesOnRecordUpdate])
答案 0 :(得分:0)
您正在使用哪个版本的Xcode和Swift?如果您使用的是 Swift 5 ,则需要使用完整的CKQuerySubscription.Options
名称,如下所示:
let noteSubscription = CKQuerySubscription(
recordType: "Notes",
predicate: NSPredicate(value: true),
subscriptionID: "notes-changed",
options: [
CKQuerySubscription.Options.firesOnRecordCreation,
CKQuerySubscription.Options.firesOnRecordUpdate,
CKQuerySubscription.Options.firesOnRecordDeletion
]
)
我希望有帮助。