Re: Differences between -isEqual: and -isEqualTo:?
Re: Differences between -isEqual: and -isEqualTo:?
- Subject: Re: Differences between -isEqual: and -isEqualTo:?
- From: Keith Duncan <email@hidden>
- Date: Fri, 19 Sep 2008 01:12:36 +0100
if [objectA isEqual:objectB] returns true then [objectA hash] ==
[objectB hash] must be true
the object's hash cannot be derived from any mutable properties of
the object
So, with both those points in mine how exactly does one implement it.
They would imply the following -
id objectA = [objectB copy];
objectA.someProperty = aValue; // aValue != objectB.someProperty
[object.A isEqual:objectB] => false
[objectA hash] == [objectB hash] => true
This makes no sense to me; though I can see the logic -isEqual: =>
hash equality (noting the arrow direction), what does one base the -
hash on for it to be identical for -isEqual: objects yet immutable
itself. How does, say an array do it?
The following code which doesn't seem to conform the guidelines:
>> array = ["one", "two", "three"].to_ns.mutableCopy
>> array.oc_hash
=> 2
>> array.addObject "three".to_ns
>> array.oc_hash
=> 3
I must be missing something truly fundamental here.
Keith Duncan
email@hidden, 33software.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden