Re: NSArrayController and sorting
Re: NSArrayController and sorting
- Subject: Re: NSArrayController and sorting
- From: Alex Clarke <email@hidden>
- Date: Sat, 11 Jun 2005 19:15:39 +1000
Hi Jeff,
The way I do this:
Firstly autorelease instead of releasing the sort descriptors. Then
they are available throughout the rest of my controller when I need
them.
After that is simply a matter of setting an ivar
IBOutlet NSArrayController * booksController;
And connecting it in IB to the NSArrayController.
Then, anytime you add a new object,
[booksController rearrangeObjects];
will do the trick.
Cheers
Alex
Alex Clarke
email@hidden
http://www.cocoalab.com
On 11/06/2005, at 12:33 PM, Jeff LaMarche wrote:
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
_______________________________________________
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