Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
June 23, 2018, 07:04:54 AM *
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
Author Topic: Prog 21.1 dealloc for display ivar  (Read 1546 times)
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.

Hero Member
Posts: 3114

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


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


Steve Kochan
Pages: [1]   Go Up
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 All rights reserved.