2
我的變量entityDescription
似乎是零,所以編譯時有一個致命錯誤。有誰知道解決方案? persistentContainer
在同一個類中聲明(AppDelegate)。NSEntityDescription是無
let entityDescription = NSEntityDescription.entity(forEntityName: "Person", in: self.persistentContainer.viewContext)
let newPerson = NSManagedObject(entity: entityDescription!, insertInto: self.persistentContainer.viewContext)
newPerson.setValue("Thomas", forKey: "first")
這僅適用於iOS的10,下面是你應該檢查阿倫EA的響應版本:http://stackoverflow.com/a/38344166/2452039 –
沒有,API語法不同的是,原則在多年前的Core Data早期版本中是一樣的。 – Mundi