Search code examples
objective-ccore-dataios6nsfetchedresultscontrollernsmanagedobjectcontext

Deleting Core Data record from Detail View of SplitView Controller


I'm trying to delete a CoreData record directly from the Detail View of the SplitViewController.

This is what I've tried:

[self.detailItem.managedObjectContext deleteObject:self.detailItem];

But it only deletes it from the TableView. When I restart the app the record is still there. How can I delete it properly? Thank you!


Solution

  • You have to save the managed object context. That writes the changes to the backing store (the SQLite file normally) so that they persist.