uitableview - iOS Swift: Displaying asynchronous data on a TableView -


i have viewcontroller tableview in it, data tableview pulled via http call asynchronously in class.

class viewcontroller1: uiviewcontroller, uitableviewdelegate, uitableviewdatasource {      override func viewdidload() {             super.viewdidload()             // additional setup after loading view, typically nib.             self.tableview.registerclass(uitableviewcell.self, forcellreuseidentifier: "cell")              myhttpclass().getdata()//initiating getting data asynchronously ... } 

myhttpclass gets data after few seconds asynchronously, not have reference of viewcontroller hand on data (ideally viewcontroller.tableview.reloaddata - need call)

is there better way handle this? how ref. viewcontroller instance when myhttp gets data? better way handle this?

well, suggest use call back,add input

 func getdata(callback:()->()){     //when finished     callback() } 

then call

myhttpclass().getdata() { () -> () in         self.tableview.reloaddata()     } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -