您使用核心数据来保存数据而不是NSUserdefaults 如何使用[[Nsuserdefaults Standarddefults] synchronize]自动同步数据; 如何使用核心数据
答案 0 :(得分:0)
然后在managedObjectContext上执行获取请求
let fetchRequest = NSFetchRequest(entityName: "Person")
var people: [Person]
do {
people = try managedObjectContext.executeFetchRequest(fetchRequest) as! [Person]
} catch let error as NSError {
print("error occured while fetching: \(error)")
}