我正在尝试快速 3 转换。我正在 swift 2 项目中从 sql 文件中预加载数据。我不确定如何在 swift 3.0 中完成这项工作?下面是我的 swift 2 appDelegate 文件。在 swift 3 中,核心数据堆栈已经发生了足够的变化,我不知道在哪里尝试重用与 swift 2 相同的代码。我正在使用的代码列在“为 SQLite 预加载添加”注释下. 谢谢
// MARK: - Core Data stack
lazy var applicationDocumentsDirectory: URL = {
// The directory the application uses to store the Core Data store file. This code uses a directory named "self.edu.SomeJunk" in the application's documents Application Support directory.
let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
return urls[urls.count-1]
}()
lazy var managedObjectModel: NSManagedObjectModel = {
// …Run Code Online (Sandbox Code Playgroud)