在Swift 3里面,需要通过viewContext访问managedObjectContext,且sharedApplication方法改为shared方法:
1 |
var context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext |
以前是这样写的:
1 |
var context = (UIApplication.sharedApplication.delegate as AppDelegate).managedObjectContext |
❤ 点击这里 -> 订阅《PAT | 蓝桥 | LeetCode学习路径 & 刷题经验》by 柳婼