Re: Search fast in NSDictionary
Re: Search fast in NSDictionary
- Subject: Re: Search fast in NSDictionary
- From: Sean Murphy <email@hidden>
- Date: Mon, 23 Oct 2006 14:33:57 -0400
On Oct 23, 2006, at 6:16 AM, xidiar wrote:
I'm searching a function to search within a string of an
NSDictionary fast as iTunes search method.
Any idea?
How can I use Hashing for it?
One way of accomplishing this is to obtain an array of either the
keys or values (depending on which components of the dictionary you
want to search through) and filter that array using a predicate.
So, call either [dict allValues] or [dict allKeys] and then use
NSArray's filteredArrayUsingPredicate: to return an new array
containing objects that match the search term.
This is just one (10.4+) method of doing this. It's probably the
easiest, but maybe performance stands to gain using another
technique. I often use Apple's and other standard library methods
and functions instead of rolling my own, since the prior are likely
to be more efficient, well tested, and heavily optimized.
Good luck,
Sean
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden