• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: UIViewControler "viewDidLoad" (Where to place "[super viewDidLoad]"?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UIViewControler "viewDidLoad" (Where to place "[super viewDidLoad]"?)


  • Subject: Re: UIViewControler "viewDidLoad" (Where to place "[super viewDidLoad]"?)
  • From: Eeyore <email@hidden>
  • Date: Tue, 9 Mar 2010 08:29:26 -0800

Here is my take on this (and I'm hoping someone will confirm it or set me straight).

On Mar 9, 2010, at 8:08 AM, jeremy wrote:

> When a XCode template contains a method that calls its superclass method (of the same name), how do I know whether the superclass call precedes or follows my custom code.

You should be building from the base up and tearing down from the top down.

> Take for example, UIViewController and its method "viewDidLoad".
>
> The template (for an iPhone application using the "view-based Application" template) includes the following method:
>
> ---
> // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
> - (void)viewDidLoad {
>    [super viewDidLoad];
> }
> ---
>
> But neither the template's comment nor the documentation for "viewDidLoad" mention whether "[super viewDidLoad]" comes before or after my custom code.


So in the case of viewDidLoad, you are building and you should call the super method before your own methods (so they can set up the base on which you will build). In the case of viewDidUnload, you are tearing down and you should call the super method after your own methods (so you can take the top off before sweeping the base out from under it).

I'm sure in some cases, you might need to place some code before and after the super call, but I am guessing that these cases are less common and would probably be clearly documented (as I think this requirement would imply some pretty tight coupling between the base class and the inherited class).

Aaron _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >UIViewControler "viewDidLoad" (Where to place "[super viewDidLoad]"?) (From: jeremy <email@hidden>)

  • Prev by Date: UIViewControler "viewDidLoad" (Where to place "[super viewDidLoad]"?)
  • Next by Date: Tab Bar Controller - what am I missing?
  • Previous by thread: UIViewControler "viewDidLoad" (Where to place "[super viewDidLoad]"?)
  • Next by thread: Tab Bar Controller - what am I missing?
  • Index(es):
    • Date
    • Thread