【发布时间】:2026-01-25 07:45:02
【问题描述】:
我正在使用 icloud 开发 coredata。 我有这个问题。 除了同步通知之外,带有 icloud 的 coredata 工作正常~ 我的代码在这里~
NSNotificationCenter.defaultCenter().addObserver(self,
selector: "changedDataOniCloud:",
name: NSPersistentStoreDidImportUbiquitousContentChangesNotification,
object: nil)
并假设收到下面的同步通知,
func changedDataOniCloud(notification: NSNotification) {
self.textView.text = "changedDataOniCloud"
}
我有 iPhone 和 iPad。 如果在 iphone 中更改了数据,则 ipad 获取同步数据并且更改通知必须响应。 同步数据工作正常,但通知不起作用!
请检查我在 github 中的项目 https://github.com/beauspiring/ios/blob/coredata_icloud/Example/ViewController.swift (分支:coredata_icloud)
【问题讨论】:
标签: swift core-data notifications synchronization icloud