Hello,
I’m working on a photo editing app (in Swift), and I want to communicate and send data back, for example from a brightness slider (grandchild controller) to the preview image (grandparent controller)… Currently I’m using protocol/delegate methods to send data back, but the problem as I create more grandchildren controllers the messier the code gets with all the extra protocol methods.
So my question is, what design pattern should I be using instead to have direct communication with the grandparent controller? I’m new to swift so I’m pretty much unfamiliar with any of the patterns used in such apps…
Are you absolutely sure that you need to have multiple ViewControllers in the same View?
What is the purpose of Controller A B and C?
A slider, for example, is simply a Control that can be implemented within a ViewController and does not need to be in its own ViewController. If the slider is there to adjust, say, brightness or contrast then that can be activated to appear to allow that adjustment to be made and you could close it by tapping an associated Done button. That could be the approach for any adjustment control as you progressively edit an image.
A: Main Viewcontroller which has the live preview image.
B: Tabbar for sliders, filters, etc…
C: Each tab is a separate viewcontroller (adjustments, filters, stickers)
Okay your tab view controller is really the first one and the main view controller (one of the tabs) is inside the first.
The other tabs are all separate view controllers but they’re all under the tab view (not technically inside the other tabs)
So you have A, tab bar controller, and B, C D etc are all inside A at the same level, not cascading down.
Depending on what information you’re passing between your different tabs you could create custom objects that contain multiple values and pass those via delegate/protocol OR you could use callbacks.
You could also save things to core data and then call them at other parts so you’re not technically passing data between VCs, but saving and then recalling it