core data的使用

1、通过UIApplication.shared.delegate as! AppDalegate 获取appDelegate

2、context = appDelegate.persistnetContainer.viewContext,得到上下文后就可以,曾山查找了。

3、查找context.fetch, NSPredicate(format:"firstName ==%@", searchString!)

4、插入获取一个NSEntityDescription.insertNewObject, data.setvalue("Peter", forKey:"username")

5、context.delete

猜你喜欢

转载自blog.csdn.net/qq_15156403/article/details/80152932