discuss-gnustep
[Top][All Lists]
Advanced

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

Re: NSNumber numberWithBool


From: Richard Frith-Macdonald
Subject: Re: NSNumber numberWithBool
Date: Fri, 8 Jun 2007 20:26:59 +0100


On 8 Jun 2007, at 20:08, Sebastian Reitenbach wrote:

Hi,

while trying to get opengroupware running with gnustep-base I stumbled about
the different return values of +NSNumber numberWithBool.
Running the following test tool:
#include <Foundation/Foundation.h>

int main (int argc, char **argv) {
        NSLog(@"numberWithInt: %@, numberWithBool: %@", [NSNumber
numberWithInt:YES], [NSNumber numberWithBool:YES]);
        NSLog(@"numberWithInt: %@, numberWithBool: %@", [NSNumber
numberWithInt:NO], [NSNumber numberWithBool:NO]);
        return 0;
}

That's not different return values of numberWithBool: and numberWithInt:

What the '%@' format string does is print the results of applying the -description method to the object, so you are logging the way the - description of the objects differs.

Now, the documentation for the -description method (Apple's documentation for the NSObject protocol) says:

'Returns an NSString object that describes the contents of the receiver. The debugger’s print-object command indirectly invokes this method to produce a textual description of an object.'

I read that as meaning that the string produced is for debug purposes, and feel that it implies that code should not depend on a particular format of the string content. So it really should not matter exactly what is printed out ... both libFoundation and gnustep- base are correct, and code which depends upon either behavior is therefore incorrect.







reply via email to

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