Selection in NSTableView during windowControllerDidLoadNib w/ CoreData+bindings
Selection in NSTableView during windowControllerDidLoadNib w/ CoreData+bindings
- Subject: Selection in NSTableView during windowControllerDidLoadNib w/ CoreData+bindings
- From: email@hidden
- Date: Fri, 17 Feb 2006 00:46:56 -0500
Hello,
I seem to be having a world of problems accomplishing the following task, although I have found an ugly workaround: I have a little app that contains an NSTableView (bound to an NSArrayController) and I track the user's selection in that view. I save the selection to the managed object context whenever a save occurs and would like to restore that selection when the document (in my document based app) loads, so in windowControllerDidLoadNib, I look it up and use the setSelectedObjects: method to restore the selection in the NSTableView. NSLog statements confirm that the proper identifiers are being saved to the moc and are loaded back out of the moc, and a log statement in tableViewSelectionDidChange: also reveals that the correct item in the table view is indeed selected...Well, not really. You see, the selection doesn't actually occur in the view (and there for while, when I had "avoid empty selection" checked, it even arbitrarily selected an item in the table.)
Ok, so I can understand that CoreData is going to do lazy loading, which means that I probably can't expect anything to be guaranteed about my table in windowControllerDidLoadNib, which also explains my problems getting a selection, and I've sort of learned my lesson. However, what I've tried that does work is adding a little timer in windowControllerDidLoadNib that delays a second, and then makes the selection.
This workaround does work like a charm, but just seems so ugly. Is there a better way someone could point me to? Or is this particular problem a limitation of CoreData that I should file an enhancement request about?
M.
_______________________________________________
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