Core Data removes last entry
I have a textField from which content is writt开发者_JS百科en to a database via core Data, which works. The table view shows the data. Everything just fine so far.
But when I close the simulator and start him again the last entry is null.
I'm using the standard core data app, with only a few changes for the second view to enter the content.
can anyone help me with that?
Are you sure that you are saving the last entry to disk? It might only be in the in-memory version but not getting saved and flushed when you quit.
To be clear: if you add multiple entries, only the last one fails to be saved?
If this is the case, where (conceptually) is the successful save happening? Are you saving in -applicationWillResignActive: ?
Is your table view data source filtering the data at all?
When you quit and restart the simulator keep in mind that it doesn't perform all of the cleanup your app would when shutdown. It doesn't do viewDidDisappear or tell your app delegate that it is becoming inactive, etc. Try tapping the Home button on the sim and then also double tap it and kill the app in the multitasking switcher. Then start your app again and see if it saved that last bit.
I tend to save my textfields to core data on every key, just in case.
精彩评论