objective-ccore-databindingnsoutlineview

NSOutlineView + NSTreeController + CoreData + Bindings Duplication of Rows


Firstly I'd like to mention that I've been using the Apple Sample Code for the AbstractTree example.

I have the bindings working up to the point that they are displaying nodes and the two buttons that are set to add: and remove: are working too.

The problem I come across is when I'm dragging one of the nodes into another node to make it a child. You can see in the image below that I made 2a and 2b to drag under 2, which they do, but they don't delete from where I dragged them from. Furthermore if I delete either of them both are deleted.

I am using this data model.

I have set the TreeController mode to Entity with it's name as Node (as in my model), which it's children key path to children. I have also bound it's MOM to the app delegate with a model key path of managed ObjectContext.

I have bound the value of the Table Column to the TreeController, its controller key arrangedObjects and its model key path as name.

I have uploaded the files here if you need them: link

Can someone help me? I'm a noob when it comes to CoreData!

Many thanks, Gareth


Solution

  • Set the fetch predicate of your NSTreeController to

    parent == nil
    

    and you can get this result. Thx for the test app :)

    enter image description here