Binding to NSViewController Presented Object

(Annotation: bindings work in code, but not in IB)

I have a window controlled by NSWindowController. To the left of the window is the source view. On the right is a tabular view showing the elements of the currently selected source.

I installed NSTreeController in my XIB window. I want its contents to be used to represent the source. This selection will drive the table view.

I am trying to split this using NSViewControllers. One view controller loads the NIB containing the source view. Another view manager will load the table view.

Seeing that I need access to the NSTreeController in the source view controller, I set it as representing the viewObject. (In fact, for this setting, done with awakeFromNib, called on the view controller, I turned the represented object into an IBOutlet).

Everything works fine when I hook the source code up in the code:

[outlineView bind:@"content" toObject:sources withKeyPath:@"arrangedObjects" options:nil]; [outlineView bind:@"selectionIndexPaths" toObject:sources withKeyPath:@"selectionIndexPaths" options:nil]; [[outlineView tableColumnWithIdentifier:@"Title"] bind:@"value" toObject:sources withKeyPath:@"arrangedObjects.title" options:nil]; 

However, I cannot reproduce this using Interface Builder. The fact is that the text field "key controller" is grayed out. Thus, I bind the column value to the file owner using the keyPath model from "presentObject.arrangedObjects.title". This does not show the desired behavior. Actually the exception is thrown: -[NSProxy doesNotRecognizeSelector:_mutatingNodes] called!

How can I use the presented object in IB? Can I create a controller in IB that acts as a proxy for the presented object? Can I configure the tree controller in the XIB view of the source code, which will change for the createdObject during NIB loading?

+4
source share
1 answer

I moved away from using createdObject. Apparently this is for model objects only.

Now I go to my tree controller using a custom socket. I continued to tweak and break the bindings in the code.

+2
source

All Articles