gnustep-dev
[Top][All Lists]
Advanced

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

Re: Problem with +numberWithBool: ?


From: Richard Frith-Macdonald
Subject: Re: Problem with +numberWithBool: ?
Date: Thu, 29 Jan 2004 14:34:52 +0000


On 29 Jan 2004, at 13:46, David Ayers wrote:

Richard Frith-Macdonald wrote:


On 29 Jan 2004, at 12:24, Manuel Guesdon wrote:


So as far as I understand [NSNumber numberWIthBool:2] will return boolN which is wrong as 2 is TRUE, isn't it ? (Or may
I need some sleep ? :-)


I agree it'll return boolN ... but 2 is not YES
Booleans in objc can be YES or NO ... this is not the same thing as true/false in C/ObjC conditionals where 0 is false and anything non-zero is true.


Checking the online docs:
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ ObjC_classic/Classes/NSNumber.html#//apple_ref/doc/initWithBool_

I read:
boolValue:
...
*Note: *The value returned by this method isn’t guaranteed to be one of |YES| or |NO|. A 0 value always means |NO| or false, but any nonzero value should be interpreted as |YES| or true.

We should go with that then.

I've had problems with inconsistencies in NeXTstep handling YES long it the past ... but if the current documentation warns about a particular behavior with a method, we should try to duplicate that behavior.






reply via email to

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