• 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
Core Data, NSOutlineView and NSSortDescriptors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Core Data, NSOutlineView and NSSortDescriptors
      • From: Carmin Politano <email@hidden>
  • Prev by Date: Something stopping power managment
  • Next by Date: Re: Request for Authors: Focused Cocoa Topic Books
  • Previous by thread: Re: Something stopping power managment
  • Next by thread: Re: Core Data, NSOutlineView and NSSortDescriptors
  • Index(es):
    • Date
    • Thread