NSArrayController and sorting
NSArrayController and sorting
- Subject: NSArrayController and sorting
- From: Jeff LaMarche <email@hidden>
- Date: Fri, 10 Jun 2005 22:33:49 -0400
I'm using Cocoa Bindings to control a table in an app, and I want the
table sorted. I added this method to my application delegate;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSSortDescriptor* sort = [[NSSortDescriptor alloc]
initWithKey:@"title" ascending:YES];
[books setSortDescriptors:[NSArray arrayWithObject: sort]];
[sort release];
}
which sorts the data. When data changes, however, the interface
doesn't maintain the sort order. I know this is probably a dumb
question, but what's the most efficient way to handle this? I know i
could create an IBAction that re-sorts the array controller and link
to it from any field that could conceivably affect the sort order,
but my gut tells me that's too inelegant to be the right solution.
I had assumed that once you set a sort descriptor for an array
controller, that it would keep everything sorted by that, but it
appears I'm wrong. Any thoughts or help is much appreciated.
Thanks,
Jeff
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden