In a UIViewController I hava a UITableView and an NSArray datalist, and I am trying to fill the tableview with datalist in [cellForRowAtIndexPath:indexPath]. In the UIViewController’s viewDidLoad, I write
datalist = [LoadingService getDatalist]
The LoadingService is loading data from network to fill the datalist and the getDatalist message return the datalist. I know in viewdidload, the datalist may has no data, so no data shown in UITableView.
My question is that how can I show datalist’data in UITableView while the datalist updates?
Answer: Don’t.
If you have no data, then show a spinner (UIActivityIndicatorView), or a progress view (UIProgressView) to at least indicate that your app is processing, else the user will become frustrated at the perceived lag. Then, when your function has returned acceptable data, call
-reloadDataand it will show your newly updated array in the table, so long as you are the delegate of the aforementioned table. A lot of servers also return responses all at once instead of chunking.If you do happen to be working with multiple responses for one input, as each one is loaded into the array/datasource, call -reloadData to give the illusion of a “realtime update”.