Swift Realm的响应结果不同
let syncServerURL = URL(string: serverUrl + "Combine")! var configuration = Realm.Configuration()
configuration.encryptionKey = Utility().getKey() as Data
configuration.syncConfiguration = SyncConfiguration(user: SyncUser.current!, realmURL: syncServerURL)
Realm.asyncOpen(configuration: configuration, callback: { realm, error in
if let realm = realm {
let results = realm.objects(Combine.self)
} else if let error = error {
print("error ******* \(error)")
// Handle error that occurred while opening or downloading the contents of the Realm
}
})
我使用此asyncOpen方法配置来获取同步的领域,响应结果显示为与领域服务器记录相同。Swift Realm的响应结果不同
let syncServerURL = URL(string: serverUrl + "Combine")! var configuration = Realm.Configuration()
configuration.encryptionKey = getKey() as Data
configuration.syncConfiguration = SyncConfiguration(user: current, realmURL: syncServerURL)
let realm = try! Realm(configuration: configuration)
let results = realm.objects(Combine.self)
我用得到同步领域,响应结果没有显示一样的境界服务器记录此方法配置。它显示不正确/过时的记录
上述结果是不同的
回答:
asyncOpen()
从服务器下载调用回调之前所有的变化,而同步构造函数立即返回本地领域实例,并在后台同步。这意味着不能保证数据是最新的。
以上是 Swift Realm的响应结果不同 的全部内容, 来源链接: utcz.com/qa/264505.html