What is better place for loading data from API- viewDidLoad, viewWillAppear or viewDidAppear?

后端 未结 6 1513
无人及你
无人及你 2020-12-16 02:03

I am making an IOS app where i am calling an API in viewDidLoad method of view controller. Now i want to reload the same view controller with the data that comes from server

6条回答
  •  渐次进展
    2020-12-16 02:34

    I think viewWillAppear is best place for loading data from API. Because viewDidLoad called once when the view is being loaded, but viewWillAppear will called when it loaded from its parent view or child view.

提交回复
热议问题