ViewDidLoad / Unload messages to super?

前端 未结 4 1987
走了就别回头了
走了就别回头了 2021-01-19 15:44

I have noticed code from other sources where the author has not added the messages to super that are shown below. I usually add them both, but I was just curious as to what

4条回答
  •  孤街浪徒
    2021-01-19 16:34

    The purpose of those methods is to notify your controller when the view it controls has finished loading, and finished unloading, in case there are things that the controller needs to accomplish in those "interesting moments".

    The code that you've included basically does nothing: it passes the messages on to the superclass implementation, without adding any processing of its own. But that's exactly what would happen if that code was omitted entirely: the message would be delivered to the lowest class in the inheritance chain that defined an implementation for the method.

提交回复
热议问题