user3051755 user3051755 - 4 months ago 28
iOS Question

iOS equivalent for onRestart()

What is the iOS equivalent for

used on Android?

is called when current activity is being re-displayed to the user (the user has navigated back to it).


I believe you need viewWillAppear method:

override func viewWillAppear(_ animated: Bool) {
    //your code here

It is called every time right before view is going to be shown. So it will be called when view is shown for the first time as well. If you want to avoid running your code for the first time viewWillAppear is called, you will have to add a flag property and check if it has been set previously.