I currently have a project with multiple views handling data and I just need some clarifiation on best practice on handing data around.
For instance: MainView displays a table of info that is added via a modal AddInfoView.
The data is passed to MainView using delegation which works well. However within AddInfoView there is a tableView cell which allows the user to select from a list of options which is presented by a push segue to another view, lets call it OptionsView.
As I can see it I have two options which would work best.
Option A: The data gets passed down the stack – Objects get passed from OptionsView to AddInfoView which then passes it to MainView to be displayed. With each view down the chain being delegates.
OR
Option B: MainView is the delegate of both AddInfoView as well as OptionsView and the data gets passed directly to that view to be displayed.
Any input would be appreciated.
I’d choose Option A if the
OptionsViewis displayed by theAddInfosViewonly. As it makes more sense, you push down the way toOptionView, so it should push up the way through AddInfosView as well.I agree that if
AddInfosViewdoesn’t need any of theOptionViewdatas returned, it would be pretty useless to pass thourhg theAddinfosView, but to keep it consistant i’d still pass through as we did it to show theOptionsView.