gpt4 book ai didi

swift - Realm.asyncOpen 不打开 Realm

转载 作者:行者123 更新时间:2023-11-30 10:50:26 25 4
gpt4 key购买 nike

我无法使用 Realm.asyncOpen 打开 Realm 。

    guard let user = userName.text else { return }
guard let password = password.text else { return }
let credentials = SyncCredentials.usernamePassword(username: user, password: password)
let syncURL = URL(string: "\(Constants.REALM_URL)/~/Pictu")!

SyncUser.logIn(with: credentials, server: Constants.AUTH_URL) { user, error in

if let error = error {
print("User Error: \(error.localizedDescription)")
}

if let user = user {
let realmConfig = user.configuration(realmURL: syncURL)
Realm.asyncOpen(configuration: realmConfig) { realm, error in
if let realm = realm {
print("Realm Open")
self.realm = realm
} else if let error = error {
print("Realm Error: \(error.localizedDescription)")
}
}
}
}

我获得了用户,但没有获得 Realm 。错误消息是操作已取消。

最佳答案

我找到了解决办法。

就我而言,它需要在配置中将 fullSynchronizacion 指定为 true。

let config = user.configuration(realmURL: syncURL, fullSynchronization: true)

关于swift - Realm.asyncOpen 不打开 Realm ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54708177/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com