I was just looking up the documentation to remind myself of the difference between isEqual: and isEqualTo: and saw that for your own custom objects to behave nicely in a collection, it apparently needs to override both isEqual: and hash.

But when I look at the specific documentation for things like NSArray and NSSet, it says that the actual comparison is done with a call to isEqual: (although it does mention that you should override hash too).

But when I look at the likes of the Cocoa Fundamentals Guide at http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html the example shows only overriding isEqual: (in the Object Comparison section).

So do I need to override hash too? If so, are there any recommendations as to how to determine the hash easily?

Thanks

Gideon
_______________________________________________

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