Hi Hank,

thanks for your quick reply.

On Mar 28, 2009, at 9:56 PM, Hank Heijink (Mailinglists) wrote:

1) If the default implementation does nothing, why must I invoke super when overriding this method?

You're right, that's confusing. Could be several answers though: maybe super does nothing visible, but still something; or maybe super could start doing something in the future. It's better to be prepared, but without more info from Apple, it's hard to say.

That's what I thought too, but "nothing" is quite specific a word and I didn't think that it would be used so cavalierly in the documentation.

2) viewDidAppear: and its friends all take a boolean argument but I don't understand what it's for. In the case of viewDidAppear:, for instance, the view has already been fully displayed, so what animations is the description above talking about? Note, for instance, that the description explicitly says

"Sent to the controller after the view fully appears and animations end."

So, again, if the animations have ended, what's the boolean argument for?

Suppose you do all sorts of stuff when animated is YES and you set it all up in viewWillAppear:. The place to clean up all that stuff would be viewDidAppear:. The boolean is there so you can coordinate the behavior with viewWillAppear:.

Ah, ok. That makes perfect sense now.

3) The documentation for each of those methods says:

"Subclasses may override this method to take an appropriate action. When doing so, they must invoke super."

Now, should I invoke super before or after my custom code?

That would depend on what your code does and what super does. If super doesn't do anything (like the docs say) it shouldn't matter.

Naturally. The real question I was asking was if anyone knew that it should be one way or another because of some other piece of documentation that I might have missed.

Generally, I like to nest things, so in viewWillAppear I will put my custom code first and then invoke super, and in viewDidAppear I'd invoke super first and then have my custom code.

Or the other way around (super first in viewWillAppear and super last in viewDidAppear). :)

Nesting has also been my policy when dealing with any paired set of methods like these.

I will send a documentation enhancement request, but I thought I'd check with the list first to make sure I'm not missing something obvious.

I'd file the request.

I'm on it.

Thanks again for answering.
Wagner

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to