[我正在学习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)
}
}
}
我希望能够订阅我喜欢的流派,然后使其能够正常工作,但遗憾的是,它没有。
自问问题以来,您是否能够自行解决此问题?我很想知道这个问题背后是否还有其他问题。