当我试图从项目中删除核心数据项时,我遇到了错误
cannot invoke 'deleteObject' with an argument list of '([AnyObject]?)'
我认为这基本上要求我投射物体,但当我尝试这个时,我得到了同样的错误。我的代码如下:
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let context = appDelegate.managedObjectContext
var error:NSError? = nil
let request = NSFetchRequest(entityName: projectEntityName)
let pred = NSPredicate(format: "projectName = %@", projectName)
request.predicate = pred
let objects = context?.executeFetchRequest(request, error: &error)
if let objectList = objects {
for thisProject in objectList {
thisProject.deleteObject(objects)
}
}
appDelegate.saveContext()
有人能帮忙吗?