我尝试使用以下代码创建CloudKit订阅:
let container = CKContainer.defaultContainer()
let database = container.publicCloudDatabase
let recordZone = CKRecordZone.defaultRecordZone()
let subscription = CKSubscription(zoneID: recordZone.zoneID, options: .FiresOnRecordCreation | .FiresOnRecordUpdate | .FiresOnRecordDeletion)
database.saveSubscription(subscription) {(subscription: CKSubscription!, error: NSError!) in
if error
{
NSLog("Error: %@", error)
}
else if subscription
{
NSLog("Saved subscription: %@", subscription)
}
}
它失败并出现此错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'CKSubscriptionTypeRecordZone subscriptions are incompatible with subscription options 7'
这是什么意思,我该如何解决?我希望在创建,更新或删除记录时收到通知。
答案 0 :(得分:4)