Swift Realm响应结果不同。

3
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方法配置来获取同步的Realms,响应结果与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)

我使用了这种方法配置来获取同步的领域,响应结果与领域服务器记录不一致。它显示不正确/过时的记录

上述结果不同。

1个回答

0

asyncOpen() 在调用回调函数之前从服务器下载所有更改,而同步构造函数立即返回本地 Realm 实例并在后台进行同步。这意味着不能保证数据是最新的。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接