本文介绍了CloudKit从当前用户获取所有订阅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我设法在Apples CloudKit中保存,更改和删除记录。我甚至收到了订阅的通知,我找不到的是,我如何列出当前用户的所有订阅。
I manage to save, change and delete records in Apples CloudKit. I even got notifications working with subscriptions, what I can not find out is, how do i list all subscriptions for the current user.
这是我到目前为止的代码:
Here is my code so far:
let operation = CKFetchSubscriptionsOperation()
operation.fetchSubscriptionCompletionBlock = { (d, e) -> Void in
println("got subscription")
if e != nil {
println("Error")
dump(e)
}
dump(d)
}
publicDatabase.addOperation(operation)
我是什么得到的是:
got subscription
Error
- <CKError 0x14db0ed0: "Invalid Arguments" (12)> #0
- 0 key/value pairs
什么是无效参数的?我如何获得所有已保存订阅的列表?
What are the Invalid Arguments? And how do i get a list of all saved subscriptions?
推荐答案
如果您想对订阅做些什么,那么您可以使用以下内容:
If you want to do something with your subscriptions, then you could use something like this:
var database = CKContainer.defaultContainer().publicCloudDatabase
database.fetchAllSubscriptionsWithCompletionHandler({subscriptions, error in
for subscriptionObject in subscriptions {
var subscription: CKSubscription = subscriptionObject as CKSubscription
..
}
}
这篇关于CloudKit从当前用户获取所有订阅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!