before this to delete a cell value in UItableview i use the following code and it works as it should .... but now it give me an error. THE ERROR: Cannot invoke 'deletedObjects' with an argument list of type '(NSManagedObject)' on the following line:
context.deletedObjects(results[indexPath.row] as NSManagedObject)
How to fix this? The codes in the function involved:
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "Default")
var appDel = (UIApplication.sharedApplication().delegate as! AppDelegate)
var context = appDel.managedObjectContext
var request = NSFetchRequest(entityName: "UserCholesterol")
request.returnsObjectsAsFaults = false
var results: NSArray = context!.executeFetchRequest(request, error: nil)!
context.deletedObjects(results[indexPath.row] as NSManagedObject)
context!.save(nil)
totalEntries = totalEntries - 1
tblLog.reloadData()
Deleting a managed object is done with context.deleteObject(anObject)
. Try this:
context.deleteObject(results[indexPath.row] as NSManagedObject)