Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

overriding viewSafeAreaInsetsDidChange needs super to be called?

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!

like image 348
jdev Avatar asked Oct 25 '25 08:10

jdev


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.

like image 152
nathangitter Avatar answered Oct 27 '25 23:10

nathangitter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!