如何在iOS 4上获得更新NSUserDefault? [英] How to get an update NSUserDefault on iOS 4?

查看:73
本文介绍了如何在iOS 4上获得更新NSUserDefault?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发iPhone应用程序,因为多任务而在iOS4上遇到问题。

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

此应用程序具有在Settings.bundle中定义的默认设置。
如果我运行我的应用程序然后我离开它(所以它在后台)。
我将更改设置并重新启动应用程序(它来自待机和方法:调用applicationDidBecomeActive())。

This application has the default settings defined in a Settings.bundle. If I run my application then I left it (so it goes in the background). I'll change the settings and restarts the application (it comes out of standby and method: applicationDidBecomeActive () is called).

NSUserDefault中的值不是更新,但是当我离开应用程序并重新启动时。价值很高。

Values in NSUserDefault are not updates, but when I leave the application and relaunch. The values are good.

有人遇到和我一样的问题吗?
我做错了什么?

Does someone experience the same problem as me? Is what I'm doing something wrong?

感谢您的建议/帮助。

推荐答案

我遇到了和你一样的问题,并通过致电

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

[[NSUserDefaults standardUserDefaults] synchronize];

in applicationDidBecomeActive

出于某种原因,您可以在应用中访问的 [NSUserDefaults standardUserDefaults] 对象与支持时的实际plist文件不同步一个应用程序在被暂停后再次变为活动状态。调用 synchronize 方法会强制同步。

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.

这篇关于如何在iOS 4上获得更新NSUserDefault?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆