【发布时间】:2020-07-20 16:35:12
【问题描述】:
如果这是一个 URL 问题,我不知道。一切正常,但在尝试异步打开领域时,出现域错误。
我的数据存储在数据库 Store.items 中。这是我的屏幕截图
我想将服务器数据同步到我的本地领域数据库。 这是我的代码
我有一个 Constants.swift 文件
import Foundation
struct Constants {
// **** Realm Cloud Users:
// **** Replace MY_INSTANCE_ADDRESS with the hostname of your cloud instance
// **** e.g., "mycoolapp.us1.cloud.realm.io"
// ****
// ****
// **** ROS On-Premises Users
// **** Replace the AUTH_URL string with the fully qualified versions of
// **** address of your ROS server, e.g.: "http://127.0.0.1:9080"
static let MY_INSTANCE_ADDRESS = "app.us1a.cloud.realm.io" // <- update this
static let AUTH_URL = URL(string: "https://\(MY_INSTANCE_ADDRESS)")!
static let REALM_URL = URL(string: "realms://\(MY_INSTANCE_ADDRESS)/appName")!
}
override func viewDidLoad() {
super.viewDidLoad()
SyncServertoLocal()
}
@objc func SyncServertoLocal(){
print("trying to sync")
let config = SyncUser.current?.configuration(realmURL: Constants.REALM_URL, fullSynchronization: true)
Realm.asyncOpen(configuration: config!) { realm, error in
if let realm = realm {
// Realm successfully opened, with all remote data available
print("Remote data available")
} else if let error = error {
// Handle error that occurred while opening or downloading the contents of the Realm
print("Opps we have a realm problem", error)
}
}
}
Opps 我们遇到领域问题 Error Domain=io.realm.unknown Code=89 "Operation cancelled" UserInfo={Category=realm.basic_system, NSLocalizedDescription=Operation cancelled, Error Code=89}
似乎没有数据正在同步,但我不知道错误的含义以及如何修复它。我该如何解决这个错误?
【问题讨论】: