开发者

NSUserDefaults BOOL returning (null)

I'm trying to pull an NSUser开发者_开发百科Defaults value from a Settings.bundle into my application. When I load up the NSUserDefaults on application load, though, an NSLog reveals that my BOOL value returns "(null)" and my String value returns the number 39540360. The weird thing is that the documentation on NSUserDefaults specifically states that

"If a boolean value is associated with defaultName in the user defaults, that value is returned. Otherwise, NO is returned."

So even if the Settings.bundle is not connected (Which I believe to be the case, anyway) it should return NO, right? Regardless, my second part to this question is how would someone call (null) as in if (maxCountEnabled == (null)){ because no nil, NULL, or NSNull method worked.


The documentation is correct, if you create a new empty project and put the following in the delegate applicationDidFinishLaunching

  NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

  BOOL tst = [defaults boolForKey:@"missingKey"];

The value for tst will be NO

Let me know if you are doing something else

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜