overriding viewSafeAreaInsetsDidChange needs super to be called?

Viewed 1795

If I override the UIViewController's func viewSafeAreaInsetsDidChange do I need to call super?

override func viewSafeAreaInsetsDidChange() {
    super.viewSafeAreaInsetsDidChange()
    // do my stuff
}

I know that if you override func viewWillAppear(_ animated: Bool) and you are not calling the super inside, your app might behave erratically. Apple in fact says that you must call super at some point. I guess that is not the case here, and that's what I wanted to confirm!

1 Answers

It's not required, but generally considered a best practice to call super on overridden methods unless there's an explicit reason not to.

If you decide that your view controller should inherit from a custom UIViewController subclass in the future, you won't have to make any code changes to run the superclass's implementation in each subclass.

Related