searching with bindings
searching with bindings
- Subject: searching with bindings
- From: John Spicer <email@hidden>
- Date: Mon, 6 Dec 2004 12:54:09 -0600
We're trying to get searching working with bindings. The code below works if the column is set to acending, but does not work if it's decending. Cany anyone point out what we're doing wrong?
-(long) findRowWithString:(NSString *) value ascending:(BOOL)ascending usingKey:(NSString *) key
{
long index = 0;
NSRange range;
range.location = 0; //from start of string
range.length = [value length];
while (index < [[theController arrangedObjects] count])
{
NSComparisonResult result = [[[[theController arrangedObjects] objectAtIndex: index] valueForKey: key] compare: value options:NSCaseInsensitiveSearch range:range];
if (ascending)
{
switch (result)
{
case NSOrderedSame:
return index;
case NSOrderedAscending:
break;
case NSOrderedDescending:
NSBeep();
return index;
}
}
else
{
switch (result)
{
case NSOrderedSame:
return index;
case NSOrderedDescending:
break;
case NSOrderedAscending:
NSBeep();
return index;
}
}
index++;
}
// at end of data so return last element as "closest" match
NSBeep();
return [[theController arrangedObjects] count]-1;
}
_______________________________________________
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