Core Data, NSOutlineView and NSSortDescriptors
Core Data, NSOutlineView and NSSortDescriptors
- Subject: Core Data, NSOutlineView and NSSortDescriptors
- From: Frank Reiff <email@hidden>
- Date: Mon, 23 Apr 2007 12:57:52 +0200
Dear all,
I'm displaying the result of a core data fetch request in an
NSOutlineView and want the results sorted by default.
I have implemented a sortDescriptors member variable in my
NSWindowController that contains an array of NSSortDescriptor and
bound those to the NSTreeController's sortDescriptors binding.
I create the descriptors like this:
NSSortDescriptor* des1 = [[NSSortDescriptor alloc] initWithKey:
@"finalName" ascending: YES selector: @selector(localizedCompare:)];
NSSortDescriptor* des2 = [[NSSortDescriptor alloc] initWithKey:
@"name" ascending: YES];
sortDescriptors = [[NSArray arrayWithObjects: des1, des2, nil] retain];
This works fine, but I want to sort numerical values correctly, e.g.
0,1,2,3,..,9,10,11,..,19,20,21 and not the default 0, 1, 11, 12, ..,
19, 2, 20, ..
This is usually achieved by using the NSNumericSearch in the mask
argument of the
- (NSComparisonResult)compare:(NSString *)aString options:(unsigned)mask
method, but sort descriptors don't allow you to specify selector
arguments..
Is there any way of doing this anyway short of adding a category to
NSString? And would that even work with CoreData?
Any help would be appreciated.
Best regards,
Frank
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden