Pregunta

Am I correct in my understanding of how to populate an NSOutlineview with an NSTreeController who is bound to two seperate entities that have a relationship between them:

My NSTreeController has a managedObjectContext bound to my appDelegate. My Object Controller for this is an entity named clients. My NSOutlineViews tableColumn is bound to the NSTreeController (and clients) key path clientCompany and this populates my NSOutlineView correctly with a list of company names.

My second entity, projects, has a relationship property called projectParent inverse-bound to a property in clients called clientChild. Through this relationship, I want the children of my NSTreeController to be made up of the relevant projects entries that have the relevant clientCompany as a parent.

To attempt this, I made clientChild the children key path in my NSTreeController and then bound my content set of the same controller to the clientChild key path of my clients entity with the Controller Key as 'selected'.

This method and various combinations don't seem to work and produce varying errors. It's only if I leave out that last 'content set' binding step that the program runs without errors on startup and has open/close icons next to the the outlineview entries, suggesting it populated like I wanted. On trying to open one of the entries, it produces an error suggesting my projects entity isn't KVC compliant with my clientChild property. I've gone over and over the bindings and can't seem to find the problem.

¿Fue útil?

Solución

From over a weeks worth of reading and researching, I believe the answer is that this isn't possible. This surprises me a little - considering all the time saver shortcuts that Interface Builder and NSTreeController provide, I thought my situation was common enough that this would have been implemented in Interface Builder or a built-in class.

I'm not in the process of creating my own class to do what I want and hopefully this answer is useful to anybody who was searching for this and couldn't find many answers (google wasn't much use).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top