Make toolbar items and WebView "communicate", how to?

Hi everyone,


I'm quite new to OS X development. In my first "serious" app, I need to make NSToolbar items change their state according to changes in other components of the UI. The application architecture is the same as the document-based cocoa application template provided by Xcode, with the following modifications:


Window Controller scene: I've added the toolbar as part of the window and set it up to use a custom controller which inherits from NSWindowController.


View Controller Scene: I've replaced the included components with a WebView and set it up to use a custom controller that inherits from NSViewController.


What I want to get is that, for instance, when the webview loads a new page, the value in a text field included in the toolbar should reflect this change. At the same time, when the user enters a new value in that field, the webview should load the new page. Yes, I am working on a browser! 😉


Anyways, I know the WebView delegate methods I should implement, but the problem is that:

- Interface Builder does not allow me to connect the "Sent action" from the text field to some code within my WebViewController;

- I do not know how to access the text field from within the WebView controller, since Interface Builder does not allow me to create an outlet.


Could you help me with that? I am struggling and I do not know how to proceed...


Thanks in advance for your support!

I'd write code in the window controller to handle the syncronization between the view controller and the toolbar items. Connecting them directly in the manner you were attempting is a bad design pattern that will come back to haunt you should you need to make any changes.

Make toolbar items and WebView "communicate", how to?
 
 
Q