Leahcim
Leahcim

Reputation: 41949

stopping and starting app in Xcode restores deleted CoreData items

I have an iOS app that used Core Data in its main view controller (MasterViewController). When I delete an item in the MasterViewController that change is reflected immediately in the table view controller however if I press stop on Xcode and then press play (command R) to start the app up again, the deleted item appears back in the list. However, if I delete the item and close the app and reopen it (without pressing start and stop on Xcode) the deleted item remains deleted. Why does pressing stop and start on Xcode reinsert the deleted item into the list? Note, I am cleaning the project. Note 2, I am testing the app on my device

Upvotes: 0

Views: 80

Answers (1)

Rob Napier
Rob Napier

Reputation: 299345

When you press "Stop" it kills the app without letting it shutdown cleanly. That means you never save your database. You need to make sure a save happens before quitting if you want it to persist.

Upvotes: 2

Related Questions