Saturday, July 26, 2008

Wiring tools

I'm not really clear on how to hook up the tool views, tools and MVC structure. I want the LevelView to load the tool views, so they will be hooked up to it as owner. From there, I can get at the controller and to the tools, but I'm not sure of how the tools can get to their views... Well, I can always guarantee that the proper view is loaded when a tool is used, I guess. Obj-C is nice that way.

So, the custom view communicates with itself freely by IBActions setup in IB. Then, in the implementations of those actions in the .m file, I can route that data to the tool by grabbing it from the view->controller. In turn, the tool can communicate back by accessing the view's tool view, and hope that the dynamic binder will take care of the message passing.

Alright, got that working! That wiring was good, I can now easily have the selection tool report selection counts in its view. There's one ugly typecast per tool, but what the hey – it works.

No comments: