Hi everyone. Awesome book, learning lots! I’m having a go at making an app using the multi-cast delegate pattern. I have a couple of questions though.
Question 1
In the playground example, the delegate object variables are created like this:
In my app, my initial controller is View Controller A. The delegate objects are other View Controllers (B, C, & D). Do I just create the variables in my initial View Controller like this:
Question 2
If I type a location in the textField (shown below) & click send, View Controller B, C, & D print out a message to the console to show that the system is working. But, when I navigate to each by clicking the relevant tab bar icon (B, C, or D), the ‘location’ label on each view controller’s screen hasn’t held onto the variable at all.
I would have thought that the value would have persisted, at least until the screen was visited, but it seems as though the value is not held in memory at all? Is this normal?
I wonder if I have to actually manually persist the location value (String) for each View Controller so that it can be recalled when navigating to each particular screen? Thoughts??
If this is just a “test” app, sure, do whatever you’d like –– it’s throwaway code that won’t ever ship, after all.
If this was actually meant for production, then no, I would not do this.
Why? You’ve tightly coupled the ViewController to ViewControllerB, ViewControllerC and ViewControllerD here. Its responsibility is likely to grow exponentially –– it will quickly become a “god” object because it has intimate details of these types.