iphone - Unexpected results from NSUserDefaults boolForKey -


after uninstalling application device , loading in debugger, attempting in setup method load flag using boolforkey. first time app runs have expectation bool not exist, since have reinstalled app. expect documentation boolforkey therefore return no.

i seeing opposite though. boolforkey returning yes, fubars initial user settings. idea why might happening or way around it?

bool stopautologin = [[nsuserdefaults standarduserdefaults] boolforkey:@"stopautologin"]; _userwantsautologin = !stopautologin; 

so stopautologin comes out "yes", unexpected.

stranger , stranger: when call objectforkey:@"stopautologin" nil object, expected. it's boolforkey returns bad value. changed code this:

// nil nsobject *wrapper = [[nsuserdefaults standarduserdefaults] objectforkey:@"stopautologin"];  // yes bool stopautologin = [[nsuserdefaults standarduserdefaults] boolforkey:@"stopautologin"]; 

please try [userdefaults synchronize];

because method automatically invoked @ periodic intervals, use method if cannot wait automatic synchronization (for example, if application exit) or if want update user defaults on disk though have not made changes.

please see: http://developer.apple.com/library/ios/#documentation/cocoa/reference/foundation/classes/nsuserdefaults_class/reference/reference.html


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -