I’m having a very consistent bug in my application:
When I store some data in the Core Data and terminated the app, then run it again some of the data is been duplicated. I debugged the code line by line in the sensitive places and realized that terminating the app causes the last edited data to be duplicated.
Any suggestions please?
When debugging core data apps, remember that just clicking “run” again or stopping the app terminates it immediately – there are no app delegate methods executed, so your context is probably not being saved.
Try to remember to click the home button before terminating the app or re-running from Xcode. This way your context will be saved. Your app will not normally be terminated “in the wild”, it is just an artefact of your testing / debugging process.