从 Swift 1 迁移到 Swift 2 以及迁移 Realm 时的另一个问题......在旧代码中,我有这行代码就像一个魅力:
ApplicationController.A._initRealm = Realm.init(path: NSBundle.mainBundle().pathForResource("initRealm",ofType:"realm")!, readOnly: true, encryptionKey: nil, error: &error)
在迁移过程之后,我将这行代码替换为:
do
{
ApplicationController.A._initRealm = try Realm.init(path: NSBundle.mainBundle().pathForResource("initRealm", ofType: "realm")!)
}
catch
{
print(error)
}
但这不再起作用。我看到以下错误消息:
Error Domain=io.realm Code=1 "open() failed: Operation not permitted" UserInfo={Error Code=1, NSLocalizedDescription=open() failed: Operation not permitted}
我不明白为什么这不起作用。我很确定该文件是在捆绑包中找到的,所以这似乎是一个安全问题?