Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 6 NSUserDefaults does NOT work

In Xcode 6: NSUserDefaults does not work in devices simulators (iPhone 5, iPhone 6, etc, simulators).

If you test on real devices, it works perfect. Someone know how to send this information to Apple? I have tried to contact Apple, but I have not received answer.

I can not test on a real iPhone6 or iPhone6 Plus because in my country is not yet available.

My code (is an example) that works perfect on devices:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

NSString *appTheme = [defaults objectForKey:@"theme_preference"];

if ([appTheme isEqualToString:@"color0"]) {

} else {

}

Probably, I did not expressed myself clearly.

The user, in "iPhone o iPad Settings" must change the settings parameters of the application.

The settings are implemented by the "Root.plist" of the "Settings.bundle".

That is, I try to test the user changes the parameters of the application. But in the source code I do not see these changes. I talk always of devices simulators (Xcode6)

App Settings

like image 205
Markus Avatar asked Sep 19 '14 08:09

Markus


1 Answers

Today I finally have fixed the problem. I have installed the latest update of Xcode (Version 6.1) and then I have reset the simulator.

Then I have accessed to my settings App. Until you open the settings of your application, settings are not copied in simulator (or real device)

It is imperative access at least once to your App settings.

like image 165
Markus Avatar answered Oct 04 '22 10:10

Markus