Re: Comparing NSDictionary woes
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