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