小编Vip*_*827的帖子

Swift 3 从 appDelegate 中的 SQL 文件预加载

我正在尝试快速 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)

core-data swift3 ios10

3
推荐指数
1
解决办法
2838
查看次数

标签 统计

core-data ×1

ios10 ×1

swift3 ×1