iPhone – NSUSERDEFAULTS is not saved in the simulator?

My [NSUserDefaults standardUserDefaults] has not been saved. I close the app and restart it and everything will be restored. I don’t have my iOS device, so I’m not sure if this will Happens on the device, but none of the other apps do it in the emulator, which leads me to believe that there is something wrong with my code. I don’t know which parts of the code I should include here, it’s simply added/modified in nsuserdefaults Key, and as I said it worked fine in the app, but after I restarted it it didn’t…

I know I can call sync, but Apple recommends against it, and Say if it is necessary, I should only call it. So.

How could something go wrong?
Thank you.

Your process may not be terminated properly, so NSUserDefaults has no chance to save. See this, mainly this.

The suggestion in the second article I linked to is to call synchronize in applicationDidEnterBackground:

Also remember, through the Xcode Stop to terminate your application usually does not save user defaults.

My [NSUserDefaults standardUserDefaults] is not saved. I close the application and restart it Everything will be restored. I don’t have my iOS device, so I’m not sure if this will happen on the device, but none of the other apps do it in the simulator, which leads me to believe that there is a problem with my code. I don’t Knowing what parts of the code I should include here, it simply added/modified the key in nsuserdefaults, and as I said it worked fine in the application, but after I restarted it it didn’t…

< /p>

I know that I can call synchronization, but Apple recommends against it, and said that if it is necessary, I should only call it. So.

How could something go wrong?
Thank you.

Your process may not be terminated properly, so NSUserDefaults has no chance to be stored. See also this, mainly this.

p>

The suggestion in the second article I linked to is to call synchronize in applicationDidEnterBackground:

Also remember that terminating your application by stopping in Xcode usually does not save User default.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1037 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.