I have the following situation:
I have a UIViewController that has embedded two Container View
s, one is hidden and one is visible. Both of those Container View
s have embedded another UIViewController
s with some elements.
I want to present a data fetched from webservice on both panels, but I want to fetch the data only once, then just parse it in a specific way, based on what panel user currently sees.
I have a method that fetches data as json:
func loadInitialDataWithoutCluster() {
print("loadInitialData");
RestApiManager.sharedInstance.getRequests { json in
if let jsonData = json.array {
for requestJSON in jsonData {
dispatch_async(dispatch_get_main_queue(),{
if let request = SingleRequest.fromJSON(requestJSON){
//how can I add those single requests
// to a list/array/whatever here that will be
// accessible from both of two other panels?
}
})
}
}
}
}
and then when it fetches all the data and (somehow) assigns it to the list/array - how can I refer to it from two different panels?