I am binding NStableView with NSMutableArray contiaining filenames and other file details. Simple biniding and sorting with compare: is not properly sorting file names like finder. Please let me know if i need to define custom selector for sorting filenames and how?
Starting from Mac OS X 10.6 just use -[NSString localizedStandardCompare:]
.
For earlier systems see Technical Q&A QA1159: Sorting Like the Finder
using custom selector in TableColumn Attribute special thanks to KennyTM
// category on NSString for custom comparison
@interface NSString (FilesComparison)
- (NSComparisonResult)compareFiles:(NSString*)file;
@end
@implementation NSString (FilesComparison)
- (NSComparisonResult)compareFiles:(NSString*)file {
return [(NSString *)self compare:file options: NSCaseInsensitiveSearch|NSNumericSearch];
}
@end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With