Re: Undo in conjunction with core data
Re: Undo in conjunction with core data
- Subject: Re: Undo in conjunction with core data
- From: Kenneth Baxter <email@hidden>
- Date: Sat, 22 Jan 2011 02:34:01 +0000 (GMT)
Thanks for that suggestion Dave. I'm trying to understand how this would work. While a tree controller would be able to represent the whole hierarchy, I think maybe for the things I am trying to achieve here, I would be easier to use an array controller on the children, and keep it at a manageable single level rather than affecting the architecture of the whole application.
So, completely separate from the UI, I create an array controller in my Node managed object, and set its entity name, MOC etc, and set the fetch predicate to be @"parent = SELF". It should then keep itself updated when the children get added or deleted in the MOC, right? (I have never used array controllers in this way before)
Now this is where I get a bit lost - so I presume that in my createChild method, I no longer need to post the ChildNodeAddedNotification, because I would be able to observe the change, and somehow know which object had been added?
And for the deletion, I'm not really clear on how to get the message to all the descendants that they are going to be removed etc.
So I am guessing that there must be some way to be notified when an object is going to be added, so I can do the pre-processing, and when it has been added, so I can do the post-processing, and ditto for the deletion, but I really don't see how this can be possible since the changes are percolating up from the MOC to the ArrayController, and I don't see anything in the array controller that seems to support this level of functionality.
Sorry for being dumb about this, but I think I must be missing the concept of what you are meaning in some fundamental way.
On 22 Jan, 2011,at 10:28 AM, Dave Fernandes <email@hidden> wrote:
One way to do this through the MVC paradigm is to bind an NSArrayController or NSTreeController to your managed object context (in Entity mode), and then have your view layer bind or use KVO with the selectedObjects or arrangedObjects attribute of the controller.
_______________________________________________
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