|
From: | Richard Frith-Macdonald |
Subject: | Re: Problem with +numberWithBool: ? |
Date: | Fri, 30 Jan 2004 11:50:04 +0000 |
On 30 Jan 2004, at 11:26, Helge Hess wrote:
On Jan 29, 2004, at 2:12 PM, Richard Frith-Macdonald wrote: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.Such an assumption (which is probably not backed by the ObjC "spec")
I have noticed that when you say 'probably' you seem to mean 'I haven't checked' :-)
Page 178 of the NeXTstep reference, section headed Defined Types ... 'BOOL A boolean value, either YES or NO'I'm sure I've seen arguments about this before - I judged the consensus to be that the BOOL type is intended to be boolean, and the fact that it's stored as a char is an
implementation detail.In practice, it matters little as long as you are consistent ... and are careful in cases where you interface to unknown code. Sometimes a problem with categories. Nevertheless, I'd consider it very poor programming to return anything other than
YES or NO from a method declared to return BOOL.
[Prev in Thread] | Current Thread | [Next in Thread] |