Re: Undo in conjunction with core data
Re: Undo in conjunction with core data
- Subject: Re: Undo in conjunction with core data
- From: Dave Fernandes <email@hidden>
- Date: Sat, 22 Jan 2011 01:52:56 -0500
On 2011-01-21, at 9:34 PM, Kenneth Baxter wrote:
> 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)
The fetch predicate would be @"parent != nil" if you want all children.
>
> 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?
Can you say what it is your application does when it gets these notifications? Are you just updating a view?
>
> 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.
Again, what do the descendants need to do when they get this message? Why not just traverse the relationships to get each of the descendants and send it a message directly?
>
> 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.
It sounds like you may be using the notifications to modify the data model. If so, there is probably a better design pattern.
>
> 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