I have couple of times, experienced problem with updating data to existing "row" in an Entity in Core Data. After saving to core data, I will do a fetch, that retrieves the old data. After a restart, the latest saved data will show. Can anyone help me please?
Thanks
Code that what update before restart:
func saveComments(){
let comment = textBox.text
let fetchRequest = NSFetchRequest(entityName: "Article")
fetchRequest.predicate = NSPredicate(format: "title = %@", (article?.title)!)
do{
let result = try moc.executeFetchRequest(fetchRequest) as? [NSManagedObject]
let articleToUpdate = result![0]
articleToUpdate.setValue(comment, forKey: "comments")
}catch{
fatalError()
}
do{
try moc.save()
}catch{
fatalError()
}
}