[Top][All Lists]

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

Re[2]: gnustep/2146: call isEqual: to find if a NSString and a NSNumber

From: Manuel Guesdon
Subject: Re[2]: gnustep/2146: call isEqual: to find if a NSString and a NSNumber are equal don't work
Date: Thu, 15 Mar 2001 17:02:24 +0100 (CET)

On Wed, 14 Mar 2001 22:02:41 +0000 Richard Frith-Macdonald <Richard 
Frith-Macdonald <address@hidden>> wrote:
 >| On Wednesday, March 14, 2001, at 09:30 PM, address@hidden wrote:
 >| > isEqual: doesn't work to compare a NSString and a NSNumber. 
 >| > NSString* a=[NSString stringWithString:@"1"]; 
 >| > NSNumber* b=[NSNumber numberWIthInti:1]; 
 >| > [a isEqual:b]] or  [b isEqual:a] always return NO 
 >| > It's hard to diagnostic until you print the class of the compared 
 >| > How does this is handled on NeXT/MacOSX ? 
 >| Not a bug ...
 >| This is correct behavior as a string is not a number so isEqual: should 
 >| return NO for a comparison of the two.
 >| In general, objects of different classes are not equal ... unless both are 
 >| of private subclasses in a class cluster.
 >| OPENSTEP and MacOS-X behave the same way.

I've came to this problem whith a dictionary in a .plist file indexed by 
"number". I've lost a lot of time to find
why a -objectForKey:[NSNumber numberWithInt:1] didn't work :-( 
When I printed the dictionary and the search key, both appeared (correctly) 
with "1".

Anyway, I see it's not easy to design a isEqual: method to handle all kind of 

Manuel Guesdon - Software Builders <address@hidden>
14 rue Jean-Baptiste Clement  -  93200 Saint-Denis  -  France
Tel: +33 1 4940 0999  -  Fax: +33 1 4940 0998

reply via email to

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