• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Differences between -isEqual: and -isEqualTo:?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Differences between -isEqual: and -isEqualTo:?
      • From: Ken Thomases <email@hidden>
References: 
 >Differences between -isEqual: and -isEqualTo:? (From: Rick Mann <email@hidden>)
 >Re: Differences between -isEqual: and -isEqualTo:? (From: Dave DeLong <email@hidden>)
 >Re: Differences between -isEqual: and -isEqualTo:? (From: Charles Srstka <email@hidden>)
 >Re: Differences between -isEqual: and -isEqualTo:? (From: Ken Thomases <email@hidden>)
 >Re: Differences between -isEqual: and -isEqualTo:? (From: Keith Duncan <email@hidden>)
 >Re: Differences between -isEqual: and -isEqualTo:? (From: "Shawn Erickson" <email@hidden>)
 >Re: Differences between -isEqual: and -isEqualTo:? (From: Jim Correia <email@hidden>)

  • Prev by Date: Re: Differences between -isEqual: and -isEqualTo:?
  • Next by Date: Re: Utility/Floating window with titlebar on left side
  • Previous by thread: Re: Differences between -isEqual: and -isEqualTo:?
  • Next by thread: Re: Differences between -isEqual: and -isEqualTo:?
  • Index(es):
    • Date
    • Thread