user3051755 user3051755 - 6 days ago 4x
Swift Question

Swift 3 equivalent for onRestart()

What is the Swift 3 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.