gnustep-dev
[Top][All Lists]
Advanced

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

Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?)


From: Richard Frith-Macdonald
Subject: Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?)
Date: Mon, 2 Feb 2004 19:43:17 +0000


On 2 Feb 2004, at 18:58, Helge Hess wrote:

On 02.02.2004, at 15:17, Richard Frith-Macdonald wrote:
Until someone (you?) found a reference in apple documentation warning that boolValue might return a non-YES/NO value from an NSNumber, I'd have said that yes, we are entitled to insist on correct usage of BOOL.

We are not talking about return values!

I don't think you and I are talking about the same things.

I think we pretty much agree that a -(BOOL)boolValue *should* return YES or NO (I wouldn't go as far and claim that it must).

Cocoa reference says:
"+ (NSNumber *)numberWithBool:(BOOL)value
Creates and returns an NSNumber containing value, treating it as a BOOL"

Which doesn't help. But to end this ridiculous discussion I tried on Panther:

NSLog(@"Hello, World!: %@", [NSNumber numberWithBool:5]);
gives
2004-02-02 19:52:35.633 BoolTest[4187] Hello, World!: true

Good idea ... I tried a test more appropriate to the issue I've been discussing -

NSLog(@"%d", [[NSNumber numberWithBool: 5] boolValue]);
gives
2004-02-02 19:28:08.227 Test[1909] 1

Which is what I would regard as the correct behavior of boolValue.

reply via email to

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