• 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: copy & isEqual nightmares
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: copy & isEqual nightmares


  • Subject: Re: copy & isEqual nightmares
  • From: Ken Thomases <email@hidden>
  • Date: Thu, 16 Feb 2012 17:54:36 -0600

On Feb 16, 2012, at 3:47 PM, Quincey Morris wrote:

> On Feb 16, 2012, at 11:44 , Ken Thomases wrote:
>
>> Well, the documentation for -[NSDictionary isEqualToDictionary:] <https://developer.apple.com/library/ios/DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/Reference/Reference.html#//apple_ref/occ/instm/NSDictionary/isEqualToDictionary:> says:
>>
>> "Returns a Boolean value that indicates whether the contents of the receiving dictionary are equal to the contents of another given dictionary."
>>
>> And:
>>
>> "Two dictionaries have equal contents if they each hold the same number of entries and, for a given key, the corresponding value objects in each dictionary satisfy the isEqual: test."
>
> That's what I meant by a hint. We *assume* that by design -[NSDictionary isEqual:] invokes -[NSDictionary isEqualToDictionary:], perhaps with a check on the class of the parameter first.

That's more than an assumption.  It's a Cocoa convention.

Are you arguing that the only thing we as Cocoa programmers can assume about invoking -isEqual: on NSString objects is what's documented in NSObject?  Because there's no separate documentation for -[NSString isEqual:], and -[NSObject isEqual:] doesn't really tell us what it means for strings to be equal.

Maybe -isEqual: just tests for object identity (equal object pointers) for NSStrings just as you had argued it does (or might) for NSMutableDictionary!

So, you better stop coding as if [string1 isEqual:string2] means anything in particular, because you haven't been promised that!  And that includes all of the indirect uses of -isEqual:, like that used to compare dictionary keys or set elements.

In other words, you're being silly.  It's clear to everyone that -[NSString isEqual:] must have semantics built on -[NSString isEqualToString:], which is clearly documented.

For what it's worth, -isEqualTo<Type>: is described in the Object Comparison section of the Cocoa Objects article in the Cocoa Fundamentals Guide.  But even there, I doubt you'll find something approaching an API contract.

Regards,
Ken


_______________________________________________

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: copy & isEqual nightmares
      • From: Ben Kennedy <email@hidden>
References: 
 >copy & isEqual nightmares (From: James Maxwell <email@hidden>)
 >Re: copy & isEqual nightmares (From: Uli Kusterer <email@hidden>)
 >Re: copy & isEqual nightmares (From: Quincey Morris <email@hidden>)
 >Re: copy & isEqual nightmares (From: James Montgomerie <email@hidden>)
 >Re: copy & isEqual nightmares (From: Quincey Morris <email@hidden>)
 >Re: copy & isEqual nightmares (From: Uli Kusterer <email@hidden>)
 >Re: copy & isEqual nightmares (From: Quincey Morris <email@hidden>)
 >Re: copy & isEqual nightmares (From: Ken Thomases <email@hidden>)
 >Re: copy & isEqual nightmares (From: Quincey Morris <email@hidden>)
 >Re: copy & isEqual nightmares (From: Ken Thomases <email@hidden>)
 >Re: copy & isEqual nightmares (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: standard user or admin user ?
  • Next by Date: Re: __block __weak - am I doing this right?
  • Previous by thread: Re: copy & isEqual nightmares
  • Next by thread: Re: copy & isEqual nightmares
  • Index(es):
    • Date
    • Thread