• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
searching with bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: searching with bindings
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: Slowwwwww releasing of text views
  • Next by Date: Binding to an NSButtonCell's title
  • Previous by thread: Re: Slowwwwww releasing of text views
  • Next by thread: Re: searching with bindings
  • Index(es):
    • Date
    • Thread