How to get an update NSUserDefault on iOS 4?

后端 未结 2 663
别跟我提以往
别跟我提以往 2021-02-15 08:52

I am developing an iPhone application, I encounter a problem on the iOS4 because of multi task.

This application has the default settings defined in a Settings.bundle. I

2条回答
  •  感情败类
    2021-02-15 09:33

    I had the same problem as you, and got around it by calling

    [[NSUserDefaults standardUserDefaults] synchronize];
    

    in applicationDidBecomeActive.

    For some reason the [NSUserDefaults standardUserDefaults] object you can access in your app isn't synchronized with the actual plist files backing it when an app becomes active again after having been suspended. Calling the synchronize method forces a synchronization.

提交回复
热议问题