Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
July 25, 2017, 01:39:06 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register Chat  
Pages: [1]   Go Down
  Print  
Author Topic: Prog 21.1 dealloc for display ivar  (Read 1435 times)
webwrx
Newbie
*
Posts: 41


« on: November 07, 2009, 04:04:02 PM »

Working through chapter 21 (finally getting my teeth into the fun stuff).

In prog 21.1 we have 2 instance variables

UIWindow *window;
UILabel *display;
...
-(void) dealloc {
  [window release];
  [super dealloc];
}

display is not mentioned in dealloc.  Is this just an oversight in the example? I've included it in my own dealloc method and not getting any over-released messages so my thinking is this was just an oversight.

I read elsewhere a couple of handy tips I find useful - anything you synthesize should be added into dealloc. Not sure if this is always 100% correct, but it helps as a reminder. Also heard on a podcast recently that it's a great idea to put your dealloc method at the top of your code as your first item under synthesize, so you are reminded to add those variables into your dealloc method.

Ben
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114



« Reply #1 on: November 08, 2009, 01:10:35 PM »

Ben,

Yes that's an oversight.  You should only release instance variables whose property attributes are copy or retain, and not assign (the default).

Cheers,

Steve Kochan
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents ゥ 2009 classroomM.com. All rights reserved.