• 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: Yet another memory management question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Yet another memory management question


  • Subject: Re: Yet another memory management question
  • From: WT <email@hidden>
  • Date: Sun, 5 Jul 2009 05:48:45 +0200

On Jul 5, 2009, at 5:34 AM, DKJ wrote:

In fact I'm now going through my code line-by-line, checking all the alloc, retain, copy etc. statements. While doing so I've come across another thing that puzzles me.

Xcode very kindly provides template code when I create new files for classes like UIViewController. (But this is still a Cocoa question.) In the template code for viewDidLoad, it provides [super viewDidLoad].

But there is no corresponding [super viewDidUnload] in the template code for viewDidUnload. Should it be there anyway?

dkj

My guess is that it should, but guessing is not necessary. Just add it, because it won't hurt if it isn't needed and it will do the right thing if it is. Not adding it, on the other hand, might do the wrong thing if it is needed. You might also want to file a bug report, pointing out the apparent discrepancy.


Just as an aside, I typically write my code using the "socks and shoes" mentality. You put your socks in first and your shoes last, but you take off your shoes first and your socks last. So, I usually write

- (void) viedDidLoad
{
    [super viewDidLoad];

    // load my stuff
}

- (void) viedDidUnload
{
    // unload my stuff

    [super viewDidUnload];
}

Note how calling the super implementation comes first in viewDidLoad but last in viewDidUnload. I use the same approach for other pairs of closely related methods, such as viewWillAppear/viewWillDisappear and viewDidAppear/viewDidDisappear.

Wagner
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Yet another memory management question (From: DKJ <email@hidden>)
 >Re: Yet another memory management question (From: WT <email@hidden>)
 >Re: Yet another memory management question (From: DKJ <email@hidden>)

  • Prev by Date: Re: Yet another memory management question
  • Next by Date: Re: Yet another memory management question
  • Previous by thread: Re: Yet another memory management question
  • Next by thread: Re: Yet another memory management question
  • Index(es):
    • Date
    • Thread