当 let realm = Realm() -> Call 可以抛出,但是没有标示 try 并且没有处理错误
When let realm = Realm() -> Call can throw, but is not marked with try and the error is not handled
我刚刚将我的项目从 Swift 1.2 迁移到 Swift 2 和 Xcode 7(应用商店版本)。我将 Realm 用于本地存储并相应地更新了库。
但是每当我在我的代码中这样做时:
let realm = Realm()
我收到 Xcode 错误:
Call can throw, but is not marked with try and the error is not handled
有什么想法吗?
这篇会对你有所帮助。
使用以下代码:
let realm = try! Realm()
我刚刚将我的项目从 Swift 1.2 迁移到 Swift 2 和 Xcode 7(应用商店版本)。我将 Realm 用于本地存储并相应地更新了库。
但是每当我在我的代码中这样做时:
let realm = Realm()
我收到 Xcode 错误:
Call can throw, but is not marked with try and the error is not handled
有什么想法吗?
这篇
let realm = try! Realm()