ios - Proper way to pass variables down to child views? (swift) -


so have main uiviewcontroller , goes down 3 levels sub controllers. loading list of data in main top level uiviewcontroller , passing down each level works fine.

i need load more data each item in list. right loading data on fly when lowest level view gets loaded. need load of data in background in top level view fine find myself loading data twice if current view hadn't been loaded yet. thinking of using global variable (a list) load of data , use in each of subviews. feel global variable not way should done.

how can load data in top level view , have propagate down lowest level views have been displayed?

there various ways handle this.

having set links pass data along each step gets old after while. when i'm writing app needs share information across multiple levels of view controllers, i'll think using data container singleton. see thread description of several options, along link developer blog including working example of swift-based data container singleton:

how share data between view controllers , other objects in swift?


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -