Re: [SOLVED] NSComparisonResult, 'double wildcard'
Re: [SOLVED] NSComparisonResult, 'double wildcard'
- Subject: Re: [SOLVED] NSComparisonResult, 'double wildcard'
- From: Martijn van Exel <email@hidden>
- Date: Mon, 12 Jan 2009 17:22:29 +0100
Again, I solved it myself. A little embarassing. But hey, I'm just
starting..
If anyone else might wonder how I got it right: I used the
RangeOfString method of NSString to get a range and then add the
object to the filtered objects array if the range's length is greater
than zero:
for (cellTitle in speciesArray) {
if([cellTitle length] < [searchText length]) continue;
NSRange range = [cellTitle rangeOfString:searchText
options:NSCaseInsensitiveSearch range:NSMakeRange(0, [cellTitle
length])];
if (range.length > 0) [soortenFiltered addObject:cellTitle];
}
The first line is to prevent NSRangeExceptions when a very short
string enters the loop as comparison base.
Thanks,
Martijn
--
martijn van exel -+- email@hidden -+- http://www.schaaltreinen.nl/
Op 12 jan 2009, om 12:25 heeft Martijn van Exel het volgende geschreven:
Hi all,
I'm looking at the TableSearch example to implement a similar view
with a UISearchBar which essentally should act as a filter for the
cells in the UITableView below it.
The TableSearch example implements an NSComparisonResult that
filters using a single wildcard (for want of a better term...): it
filters by comparing the string entered in the search bar to the
beginning of the strings in the array that fills the table view.
What I want instead is to filter on any part of the string (using a
'double wildcard' much like the SQL 'LIKE' operator.
Can I implement this using a NSComparisonResult?
Thanks,
--
martijn van exel -+- email@hidden -+- http://www.schaaltreinen.nl/
_______________________________________________
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