FROM : Ricky Sharp
DATE : Fri Apr 08 23:03:07 2005
On Apr 8, 2005, at 2:50 PM, Lee Morgan wrote:
> Hey all,
> I'm having a problem sorting my NSTableColumn "properly".
> It's filled with NSString objects which currently appear like so..
>
> - 1
> 1
> 1/2
> 10
> 1A
> 2
>
> However I need them to appear like so (the "proper" way)
>
> - 1
> 1/2
> 1
> 1A
> 2
> 10
>
> I'm tried searching the archives, docs, and google but I haven't found
> anything on how to correct this. Sorting the "1/2" case isn't that big
> of a deal, it can pretty much fall where it falls, but the "1A", and
> "2" appearing after "10" is a killer for me.
When comparing your strings, use the NSNumericSearch option
For example, in one of my model's compare: methods, I do this:
- (NSComparisonResult)compare:(IIStudent*)anotherStudent;
{
return [[self studentName] compare:[anotherStudent studentName]
options:NSLiteralSearch | NSNumericSearch | NSCaseInsensitiveSearch];
}
___________________________________________________________
Ricky A. Sharp mailto:<email_removed>
Instant Interactive(tm) http://www.instantinteractive.com
DATE : Fri Apr 08 23:03:07 2005
On Apr 8, 2005, at 2:50 PM, Lee Morgan wrote:
> Hey all,
> I'm having a problem sorting my NSTableColumn "properly".
> It's filled with NSString objects which currently appear like so..
>
> - 1
> 1
> 1/2
> 10
> 1A
> 2
>
> However I need them to appear like so (the "proper" way)
>
> - 1
> 1/2
> 1
> 1A
> 2
> 10
>
> I'm tried searching the archives, docs, and google but I haven't found
> anything on how to correct this. Sorting the "1/2" case isn't that big
> of a deal, it can pretty much fall where it falls, but the "1A", and
> "2" appearing after "10" is a killer for me.
When comparing your strings, use the NSNumericSearch option
For example, in one of my model's compare: methods, I do this:
- (NSComparisonResult)compare:(IIStudent*)anotherStudent;
{
return [[self studentName] compare:[anotherStudent studentName]
options:NSLiteralSearch | NSNumericSearch | NSCaseInsensitiveSearch];
}
___________________________________________________________
Ricky A. Sharp mailto:<email_removed>
Instant Interactive(tm) http://www.instantinteractive.com
| Related mails | Author | Date |
|---|---|---|
| Lee Morgan | Apr 8, 21:50 | |
| Ricky Sharp | Apr 8, 23:03 | |
| Tom Bradford | Apr 8, 23:11 | |
| Lee Morgan | Apr 8, 23:50 | |
| Lee Morgan | Apr 9, 03:21 |






Cocoa mail archive

