Xcode 6 NSUserDefaults NOT working

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

If you test on real devices, it works great. Does anyone know how to send this information to Apple? I tried to contact Apple, but I did not receive a response.

I can not test the real iPhone6 ​​or iPhone6 ​​Plus, because in my country is not yet.

My code (example) that works great on devices:

 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSString *appTheme = [defaults objectForKey:@"theme_preference"]; if ([appTheme isEqualToString:@"color0"]) { } else { } 

I guess I did not express myself clearly.

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

Settings are made using "Root.plist" in "Settings.bundle".

That is, I'm trying to check if the user is changing application settings. But in the source code I do not see these changes. I always talk about device simulators (Xcode6)

App settings

+7
ios8 xcode6 nsuserdefaults
source share
5 answers

Today, I finally fixed the problem. I installed the latest Xcode update (version 6.1) and then I have a reset simulator.

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

Access to your application’s settings is required at least once.

+2
source share

Try saving the data as follows:

 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:@"color0" forKey:@"theme_preference"]; [defaults synchronize]; 

And then call it later:

 NSString *appTheme = [defaults objectForKey:@"theme_preference"]; if ([appTheme isEqualToString:@"color0"]) { } else { } 
0
source share

This is a common problem now with xCode6 and ios8.

What I found is Reset the contents and settings of the simulator whenever you encounter this NSUserDefaults problem.

when I removed the application from the simulator, userdefaults were not cleared.

Then I reset my simulator and it worked great for me.

So, until the apple fixes it, the best way to test on a simulator is with a Reset simulator when you want to uninstall an application.

It worked for me. Hope this helps another.

0
source share

This is an iOS simulator error, you should go to iOS Simulator> Reset Content and Settings on Reset.

0
source share

Go to the iOS simulator in the menu, and then click reset the content settings, now your problem should be resolved.

0
source share

All Articles