• 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: Comparing NSDictionary woes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Comparing NSDictionary woes


  • Subject: Re: Comparing NSDictionary woes
  • From: Milo Bird <email@hidden>
  • Date: Mon, 23 Jul 2007 01:06:12 +0100

Dear Ken,

No, -isEqual: and -description are separate methods, with separate logic. Objects with identical descriptions may be equal, but depending on the implementation of those two methods they may well not be.

For example, say you have an object representing a file on disk. You will probably want to judge equality by comparing the paths of the two files. However, when implementing the -description method you may decide to print just the filename. In that case, two objects representing different files with the same filename would have the same description but would not be equal.

You might as well expect that all Johns in the world are actually the same person, because their name is written the same.

AFAIK there is no problem with NSDicitionary's -isEqual:/- isEqualToDictionary:, so this must be to do with the objects you are putting into it. Please post some code.

Cheers,

Milo


On 23 Jul 2007, at 00:46, Ken Tozier wrote:

If they are identical in the printout, wouldn't that mean they are equal? If by tested, you mean have I used isEqualToDictionary" then yes. That was the first thing I tried. Is that what you meant?

The "description compare" was an attempt to compare two dictionaries whose values I know for a fact are identical (at least when printed to the run log)

I was able to come up with a workaround by serializing one dictionary into an associative PHP array, sending it off to a server script which compares the serialized dictionary with another associative array built from values in a database. This is just as good for my purposes as that's basically what I was doing on the Cocoa end, periodically comparing a dict stored in an object with the values stored in a database.
_______________________________________________

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: Comparing NSDictionary woes
      • From: Ken Tozier <email@hidden>
References: 
 >Comparing NSDictionary woes (From: Ken Tozier <email@hidden>)
 >Re: Comparing NSDictionary woes (From: mmalc crawford <email@hidden>)
 >Re: Comparing NSDictionary woes (From: Ken Tozier <email@hidden>)
 >Re: Comparing NSDictionary woes (From: mmalc crawford <email@hidden>)
 >Re: Comparing NSDictionary woes (From: Ken Tozier <email@hidden>)

  • Prev by Date: Re: Comparing NSDictionary woes
  • Next by Date: Re: Comparing NSDictionary woes
  • Previous by thread: Re: Comparing NSDictionary woes
  • Next by thread: Re: Comparing NSDictionary woes
  • Index(es):
    • Date
    • Thread