I have preloaded data from a .csv file into coredata. I am fetching the data in the following way
var places:[Places] = []
in viewDi
Your current code is:
if let managedObjectContext = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext {
let place : Places = Places()
place.isFavourite = cell.isFavouriteLabel.text
do{
try managedObjectContext.save()
} catch let error as NSError{
print(error)
}
}
That would create a new place (if it worked), but you need to update an existing one.
You have the places
returned from managedObjectContext.executeFetchRequest
.
So you need to get something like places[index_of_the_cell_in_question].isFavourite = cell.isFavouriteLabel.text
and then managedObjectContext.save()
.