Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Restoring sort order to NSTableView



I have an NSArrayController hooked to an array (of NSDictionary) and bound
to columns in a NSTableView. It all works fine. I added an auto save name to
the table so that the column widths and ordering are restored upon launch,
but can't get it to restore the sort order.

I can force a sort with:

NSMutableArray      *descriptors = [NSMutableArray arrayWithCapacity:0];
NSSortDescriptor    *descriptor;

descriptor=[[NSSortDescriptor alloc] initWithKey: @"name" ascending: YES
selector: @selector(compare:)];

[[myTableView tableColumnWithIdentifier:@"name"]
setSortDescriptorPrototype:descriptor];

[descriptors addObject:descriptor];
[descriptor release];

[myTableView setSortDescriptors:descriptors];

Of course this sorts by a fixed column. I was thinking I could call
sortDescriptors before quitting and save restore this using an NSData, but
really this should be automated.

How do do it?

Thanks,

Trygve


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.