Alvin123
Alvin123

Reputation: 53

How to automatically reload the data from viewcontroller?

I am trying to find the solution for how to automatically reload all the data in view controller but i can't find any. Right now i am using push to refresh to reload the button/title/data in view controller viewDidload() but i want to have it automalliy reload everything every time i come back to this viewcontroller. For example when app lunched, it load view controller A then i clicked on the button to go View controller B but i want to controller A to refresh everything after back from B so how can i do that?

Thanks

Upvotes: 1

Views: 994

Answers (1)

maxwell
maxwell

Reputation: 4166

For this, there is a method viewWillAppear

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    reloadData()
}

func reloadData() {
    //All you need to update
}

Upvotes: 2

Related Questions