Re: NSCountedSet and NSString values question
Re: NSCountedSet and NSString values question
- Subject: Re: NSCountedSet and NSString values question
- From: Philip Mobley <email@hidden>
- Date: Fri, 13 Aug 2010 17:13:39 -0700
On Aug 13, 2010, at 4:14 PM, Greg Guerin wrote:
>> My question is basically how does NSCountedSet handle string values, are they interpreted by their string values or by their object values? If they are by object, then I need to do more work to pull the exact key object from the NSDictionary.
>
> NSCountedSet inherits from NSSet and NSMutableSet, both of which use the hash and isEqual: methods of contained objects. See the reference docs for each.
>
> In general, docs for a class do not repeat descriptions from a superclass, unless there is a difference. So to fully understand what any class does, you must often read the superclass's docs as well as the docs of the class you wish to use.
Thank you for your replies...
I guess the issue is really more related to the fact that I didn't understand how NSStrings work with the -isEqual: function. I have been reading up on it, and have read some interesting things including:
http://www.drobnik.com/touch/2009/11/the-world-on-an-nsstring/
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.
Short answer... yes. NSSet and subclasses *effectively* compares the value of the NSString and not the object address.
_______________________________________________
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