Re: NSArrayController Selection and Managed Object Context Undo
Re: NSArrayController Selection and Managed Object Context Undo
- Subject: Re: NSArrayController Selection and Managed Object Context Undo
- From: Richard Somers <email@hidden>
- Date: Mon, 17 Oct 2011 16:02:37 -0600
SOLVED
On Oct 6, 2011, at 8:40 AM, Keary Suska wrote:
> AFAIK you will need to manage selection restoration semantics yourself, and it may not be easy and it may be fragile. Note also that the preserve and avoid empty selection settings will also have an effect. That being said, the approach would be--before adding/deleting outside the controller--to grab the managed object context's undo manager, open an undo group, add selection restoration operations, perform the operation, then close the group. This should cause the undo to restore selection. Of course, this is theory, as I haven't had to actually do it, and more experienced Core Data wranglers may have more to add.
I feel like I have been to the North Pole and back with this issue. But this advice proved very valuable in the end. I simply wrote a pair of controller selection methods, one the inverse of the other. The first registers the second method and the second registers the first method with the managed object context's undo manager. All the code was 16 lines long. So far it works very well.
On Oct 6, 2011, at 1:16 PM, Quincey Morris wrote:
> Bind the array controller's "selectionIndexes" binding to a NSIndexSet property in your data model ...
My data is inherently non-ordered. But for ordered collections I think this would work well.
Thanks for the comments and suggestions.
--Richard
_______________________________________________
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:
This email sent to email@hidden