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])
Run Code Online (Sandbox Code Playgroud)
Which version of Xcode and Swift are you using? If you are on Swift 5, you need to use the full CKQuerySubscription.Options name like this:
let noteSubscription = CKQuerySubscription(
recordType: "Notes",
predicate: NSPredicate(value: true),
subscriptionID: "notes-changed",
options: [
CKQuerySubscription.Options.firesOnRecordCreation,
CKQuerySubscription.Options.firesOnRecordUpdate,
CKQuerySubscription.Options.firesOnRecordDeletion
]
)
Run Code Online (Sandbox Code Playgroud)
I hope that helps.
| 归档时间: |
|
| 查看次数: |
364 次 |
| 最近记录: |