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.
Comments
Post a Comment