Not sure about NSTableViews, but with NSOutlineViews, which I'd think behave the same way, the secret sauce is to make sure that your items have all of persistentObjectForItem, initWithPersistentObject, isEqual and hash consistently implemented. Reason being that what is stored to your prefs file is the persistent object of the selected item, and on restart the framework first compares hashes between the "reconstituted" persistent object and what has been loaded into the view, then, if those match, calls isEqual.

Sandy

On Apr 13, 2009, at 5:32 AM, Martin Stanley wrote:

I have a core-data document-based application that uses a NSTableView with an NSArrayController as its data source. I have managed to figure out the magic IB incantations required to save the column sort, order and hidden data to the shared NSDeafulsController.

What I would like to do is to also save the current selection of the table across application invocations. I have tried the obvious: - bind the array controller's selected indexes to the Shared Defaults controller - no luck - bind the tableview's selected indexes to the Shared Defaults controller - no luck I even tried to get the select programmatically, but when I tried the callback methods I thought appropriate:
        - windowControllerDidLoadNib
        - applicationDidFinishLaunching
I found that the array controller was not yet loaded with data and therefore had no selection.

Can anyone shed some light on this?

Thanks,
Martin


_______________________________________________

Cocoa-dev mailing list ([email protected])

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/mcguffogl%40gmail.com

This email sent to [email protected]

_______________________________________________

Cocoa-dev mailing list ([email protected])

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/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to