Philip Mobley wrote:

The author of the article is somewhat unsure whether using - isEqual: is safe, but after looking at the [NSString hash] documentation I feel confident in my current implementation.

That author is confused, and should consult some reference documentation. It's really quite simple. In the words of the NSObject protocol reference doc, "This method defines what it means for instances to be equal." Any concerns over the details of the implementation, or reliance upon those details, runs counter to the principles of object-oriented programming and encapsulation.


Short answer... yes. NSSet and subclasses *effectively* compares the value of the NSString and not the object address.


Cocoa Fundamentals Guide,
  Cocoa Objects section,
  Introspection sub-section,
  Object Comparison heading.

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ CocoaFundamentals/CocoaObjects/CocoaObjects.html

It might be useful to read the whole guide if it's new to you, or read it again if you've read it before. I often find that rereading fundamentals gives new insights.

Also see the Discussion under NSString isEqualToString:

“Literal” when applied to string comparison means that various Unicode decomposition rules are not applied and Unicode characters are individually compared. So, for instance, “Ö” represented as the composed character sequence “O” and umlaut would not compare equal to “Ö” represented as one Unicode character.
  -- GG


_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to