Re: Selecting an object based on the value of one of its attributes
Re: Selecting an object based on the value of one of its attributes
- Subject: Re: Selecting an object based on the value of one of its attributes
- From: vincent habchi <email@hidden>
- Date: Wed, 28 Apr 2010 08:23:08 +0200
Le 28 avr. 2010 à 04:37, Lynn Barton a écrit :
> Newbie question: Consider an array of dictionary objects, all of the same class. One of the ivars of that class is an NSString which is unique for each instance. Does there already exist a method that will identify the one dictionary object that has a given value of that ivar, without me having to write code to examine all of the objects one by one?
Use a hash code. That's the way NSDictionary class search for keys. It is way faster than simple linear search, especially if you have thousands of elements. But it is more code and memory expensive.
Vincent
_______________________________________________
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