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}
これが機能しない理由がわかりません。ファイルがバンドル内にあることは確かですが、セキュリティ上の問題のように見えますか?