views:

98

answers:

2

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?

+2  A: 

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
AmitSri
A: 

Hello there I'm trying to do the same thing. It's just that I need to list the file names in a NSTableView. Is it possible for you to help me out with the general code ? I'm a newbie, and it has been days I started learning obj-c :D so please go easy on me :$ :D

John Oesbay
Please check my answer above with NSString category. you need to define this in somewhere at the top of .m class and then in the IB for NSTableView Column Attributes set the selector to compareFiles: thats all you need to do.Hope this helps
AmitSri
Also make sure you will bind NSTableView Delegate and Datasource to .m for complete implementation
AmitSri