将ID为[...]的记录预订保存到服务器时出错:部署的架构UUID与提供的父UUID不匹配

时间:2019-07-20 07:17:28

标签: swift runtime-error uuid cloudkit

我正在学习Swift并完成了Paul Hudson的Swift Project 33的黑客攻击(录制音频并将其上传到CloudKit上),即使该应用程序可以正常工作并且可以正确地将数据保存并提取到云端,但我在控制台中仍然遇到此错误:
将ID为391D8B41-2BA8-4B25-8693-F87237237F5B的记录预订保存到服务器时出错:部署的架构UUID与提供的父UUID不匹配。

部分无效的代码似乎是我设置了一种首选类型的,当其他用户上传我选择的这种类型的新音频时,会通知该类型。当我点击“保存”时,我在Xcode控制台中收到该错误。

我不知道在哪里寻找错误,因为本教程未使用CloudKit仪表板UI中的最新更改进行更新,并且他似乎没有得到我同样的错误。

这很长,但是我想问题出在saveTapped()方法中。如果您知道该项目并且认为问题还在其他地方,请告诉我,我将使用正确的代码更新问题。

@objc func saveTapped() {
    let defaults = UserDefaults.standard
    defaults.set(myGenres, forKey: "myGenres")

    let database = CKContainer.default().publicCloudDatabase

    database.fetchAllSubscriptions { [weak self] (subscriptions, error) in
        if error == nil {
            if let subscriptions = subscriptions {
                for subscription in subscriptions {
                    database.delete(withSubscriptionID: subscription.subscriptionID) { (str, error) in
                        if error != nil {
                            let errorAC = UIAlertController(title: "Error", message: "There was an error deleting your subscription: \(error!.localizedDescription)", preferredStyle: .alert)
                            errorAC.addAction(UIAlertAction(title: "OK", style: .default))
                            self?.present(errorAC, animated: true)
                        }
                    }
                }

                for genre in self!.myGenres {
                    let predicate = NSPredicate(format: "genre = %@", genre)
                    let subscription = CKQuerySubscription(recordType: "Whistles", predicate: predicate, options: .firesOnRecordCreation)

                    let notification = CKSubscription.NotificationInfo()
                    notification.alertBody = "There's a new whistle in the \(genre) genre."
                    notification.soundName = "default"

                    subscription.notificationInfo = notification

                    database.save(subscription) { (result, error) in
                        if let error = error {
                            print(error.localizedDescription)
                        }
                    }
                }
            }
        } else {
            let errorAC = UIAlertController(title: "Error", message: "There was an error fetching your subscription: \(error!.localizedDescription)", preferredStyle: .alert)
            errorAC.addAction(UIAlertAction(title: "OK", style: .default))
            self?.present(errorAC, animated: true)
        }
    }
}

我希望能够订阅我喜欢的流派,并且以后能够使用,但是可惜的是,

0 个答案:

没有答案