Welcome, Guest. Please login or register.
Did you miss your activation email?
May 25, 2017, 05:28:43 AM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Chapter Study
| | |-+ Chapter 21 - Writing iPhone Applications
| | | |-+ Prog 21.1 dealloc for display ivar
Pages: [1] Go Down
Author Topic: Prog 21.1 dealloc for display ivar (Read 1415 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:

Login with username, password and session length

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 (c) 2009 classroomM.com. All rights reserved.