我查看了Apple的:
Xcode 8发行说明:https:
//developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/Introduction.html
从Swift 2.2迁移到Swift 2.3或Swift 3
https://swift.org/migration-guide/
在macOS 10.12,iOS 10.0,tvOS 10.0和watchOS 3.0中的核心数据有什么新功能
https://developer.apple.com/library/content/releasenotes/General/WhatNewCoreData2016/ReleaseNotes.html#//apple_ref/doc/uid/ TP40017342-CH1-DontLinkElementID_1
还有很多其他......但是,应该从Apple的核心数据编程指南中获得的一个文档尚未从Swift 2更新
.https://developer.apple.com/library/content/documentation/Cocoa/概念/ CoreData/FetchingObjects.html#// apple_ref/DOC/UID/TP40001075-CH6-SW1
理想情况下,我正在寻找类似这样的东西,但对于Swift 3.
https://www.raywenderlich.com/115695/getting-started-with-core-data-tutorial
任何线索都会非常感激.
每个汤姆的评论(下面)我错过了什么步骤?
1)创建一个新项目"测试"
2)选择使用CoreDate(这会创建Test.xcdatamodeld)
这将使用以下内容自动填充AppDelegate(删除默认注释):
func applicationWillTerminate(_ application: UIApplication) {
self.saveContext()
}
lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentContainer(name: "Test")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
func saveContext () {
let context = persistentContainer.viewContext
if …
Run Code Online (Sandbox Code Playgroud)