On 29/10/2010, at 10:44 PM, Roland King wrote:

> It should work the way you've done it in a NSDictionary. 
> 
> Yes the numbers created by +numberWithUnsignedInteger: are distinct objects 
> (normally, if I use low numbers they actually aren't, one of Cocoa's little 
> optimizations I guess), however they compare as equal with isEqual: or 
> isEqualToNumber:
> 
> NSDictionary uses isEqual: so it should find it with no issue. I just threw 
> together a 10 line program which does that, puts an entry into a dictionary 
> keyed on an NSNumber representation of an NSUInteger and gets it out with 
> another distinct NSNumber of the same NSUInteger, it finds it. I did also 
> test in that case that the two NSNumbers were distinct, they were. 


Of course, you're quite right, which is why I thought it would work in the 
first place.

Having put it back to not using the static array, it's now working fine! 
Gremlins....

OK, need to try and work out why this didn't work first time around...

--Graham




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to