How can I check my realm schema version without opening the realm file?

我与影子孤独终老i 提交于 2019-12-05 11:54:13

Technically you can't check the schema version without accessing the Realm file at all, but you don't need full access and specify a matching schema to read just the schema version. We have functions to allow exactly that.

From Objective-C, you can use the class method:
+[RLMRealm schemaVersionAtPath:error:]

From Realm Swift, you can use the free function: schemaVersionAtPath(_:encryptionKey:error:).

I found this answer here

let configCheck = Realm.Configuration();
do {
     let fileUrlIs = try schemaVersionAtURL(configCheck.fileURL!)
    print("schema version \(fileUrlIs)")
} catch  {
    print(error)
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!