In UIViewController's documentation, Apple suggests calling the super at some point in the implementation of viewWillAppear, viewDidAppear, viewWillDisappear, viewDidDisappear, etc... For example, the discussion on viewDidDisappear is:
You can override this method to perform additional tasks associated with dismissing or hiding the view. If you override this method, you must call super at some point in your implementation.
My question is does it matter when the super method is called and, if so, what is the correct time to call it? Should super be called as the first line of the method, the last line, or somewhere in the middle depending on your particular needs?
In viewDidAppear
call super
first so that your calls will override.
In viewWillDisappear
it seems to be a toss up, I have researched that extensively and could not find a conclusive answer and it seems to be 50/50. I have decided to call super
last in my code in the same manner we call super
last in dealloc
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With