开发者

Update UI on settings change - Objective-C

For my application, I am storing a url in a settings panel so the user is able to edit it.

After the application is already open, I want to take care of the use case where the user presses the home button to background the application, goes into the settings panel, changes the url, and then wakes the application back up. The problem I am running into is when the application wakes back up and I try and get the value from the settings开发者_JS百科 again, it is the same. The application only notices the change if the app is fully exited and then restarted.

Currently I am reading the settings like this:

NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];
NSString *url = [settings stringForKey:"@url"];

This is wrapped inside of a function that gets invoked when UIApplicationDidBecomeActiveNotification gets fired.


Try to synchronize the defaults after setting the value :

[settings synchronize];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜