On Feb 19, 2011, at 6:08 PM, Andy Lee wrote:
> I just did a quick test and confirmed that you do get two different instances 
> with the same hash, but they are in face isEqual: to each other and hence 
> their presence in a set is detected, as I would expect.
> 
>   NSNumber *one = [NSNumber numberWithLongLong:1];
>   NSNumber *another = [NSNumber numberWithLongLong:1];
>   NSSet *set = [NSSet setWithObject:another];
> 
>   NSLog(@"+++ one %p, hash = %ld -- another %p, hash = %ld -- is eq = %d, 
> contains one = %d, contains another = %d",
>         one, [one hash], another, [another hash], [one isEqual:another], [set 
> containsObject:one], [set containsObject:another]);

Whoops, actually I got the same instance using 1, presumably because NSNumber 
keeps a few low number instances cached. What I said above is true if I retry 
with 123456789.

--Andy

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to