help-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strange behaviour?


From: Jeff Teunissen
Subject: Re: strange behaviour?
Date: Sat, 22 Jan 2005 05:18:58 -0500

Christian Klein wrote:

[snip]

>     NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
>     if([ud objectForKey: @"NSWriteOldStylePropertyLists"] == NO)
>         NSLog(@"returned NO\n");
>     else
>         NSLog(@"returned YES\n");
> 
>     if(GSMacOSXCompatiblePropertyLists() == NO)
>         NSLog(@"returned NO\n");
>     else
>         NSLog(@"returned YES\n");
> 
> and my GNUstepDefaults looks like this:
> {
>     NSGlobalDomain = {
>                 NSWriteOldStylePropertyLists = 0;
>     };
> }
> 
> when the code above runs, it outputs:
> 2005-01-21 20:57:57.000 ab[61277] returned YES
> 2005-01-21 20:57:57.000 ab[61277] returned NO
> 
> Shouldn't the result be the same?

I see Richard has given the short explanation, so I will give the long
version so that you can understand /why/ it is so. :)

NSUserDefaults -objectForKey: will only return nil (interpreted as NO here,
because nil and NO have the same value) if the key does not exist. What it
returned was an NSString containing "0".

If you had used -boolForKey:, then it would have returned NO, having checked
the string for a numeric value and the strings "YES", "NO", as well as
probably "true", and "false" for Mac OS X compatibility.

-- 
| Jeff Teunissen  -=-  Pres., Dusk To Dawn Computing  -=-  deek @ d2dc.net
| GPG: 1024D/9840105A   7102 808A 7733 C2F3 097B  161B 9222 DAB8 9840 105A
| Core developer, The QuakeForge Project        http://www.quakeforge.net/
| Specializing in Debian GNU/Linux              http://www.d2dc.net/~deek/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]