【问题标题】:CloudKit Get actual Object from Record ID in OSXCloudKit 从 OSX 中的记录 ID 获取实际对象
【发布时间】:2016-08-17 12:27:59
【问题描述】:

我正在尝试使用 CKSubscription 订阅更改。我正在关注 Apple 的文档,该文档似乎非常笼统且不完整。 Link to Apple Doc

我已经知道通过AppDelegate 中的didReceiveRemoteNotification 方法将记录ID 发送到我的应用程序,并且我有我的记录ID:使用此代码:

func application(application: NSApplication, didReceiveRemoteNotification userInfo: [String : AnyObject]) {
        let cknNotification = CKNotification(fromRemoteNotificationDictionary: userInfo as! [String:NSObject])

        if cknNotification.notificationType == .Query,
            let queryNotification = cknNotification as? CKQueryNotification {
            let recordId = queryNotification.recordID
            print(recordId)
        }

如何将 CKNotification 转换为存储在 Cloudkit 中的实际对象?我是否需要执行另一次提取,或者是我只需要转换的 CKNotification 中包含的数据。

【问题讨论】:

    标签: macos cloudkit cksubscription cknotification


    【解决方案1】:

    看来我已经解决了。

    通知仅让您知道它们已更改。您需要完成提取新记录并更新它们的工作。 (确实有道理)

    privateCloudDatabase().fetchRecordWithID(recordId!, completionHandler: { (recordfetched, error) in

                //Check the Record Type if multiple.. I only have one type.
       let myRecordType = recordfetched?.recordType
                let myObject = mySuperObject(record: recordfetched!)
                print("done")
            })
    

    // 我可能应该添加更多可选检查 - 但上面只是说明了解决方案以及它是多么简单。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-10
      • 1970-01-01
      • 1970-01-01
      • 2017-04-20
      • 2017-07-11
      • 1970-01-01
      • 2015-07-19
      相关资源
      最近更新 更多