This question is for an OSX app, but the same principle can be for iOS.
I have a NSWindowController on storyboard with the following setup.
A. MainWindowController has as subviews:
1) A toolbar with a button
2) A SubVcA
viewController with its own content
B. SubVcA
has as its content, SubVcB
viewController's view
C. SubVcB
has a function ButtonPressed
The goal is to trigger the button pressed function in the SubVcB
viewController by clicking on the toolbar button.
The way i've been doing it is to have a chain of method implementations from the mainWindowController to the target viewController like so:
MainWindowController call method on SubVcA
-->SubVcA call method on SubVcB
---> SubVcB call method buttonPressed
This works, but it gets messy when the controller stack gets about 4 levels deep. It also gets even more messy, when the SubVC(B) has to send data back up to the MainWindowController, because in-order to have encapsulation (as in not letting the SubVC(B) have too much information about its calling viewControllers), I have to implement delegate methods back up the chain. It gets even messier when you have more than one toolbar button.
Now...I have just started messing around with the firstResponder item on Storyboard
And i realize that it pops up a HUGE list of all methods that are implemented throughout your app with -(IBAction)
.
So my question now is: In order to reduce method clutter up and down the hierarchy of views, is it good app design to simply hook up the MainWindowController's toolbar button action, directly to the buttonPressed method in the SubVc(B) viewController using the firstResponder object on the storyboard?
Also, are there any other design patters out there that will reduce clutter?