Welcome, Guest. Please login or register.
Did you miss your activation email?
July 23, 2016, 07:56:31 PM
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 8 - Inheritance
| | | |-+ dealloc question
Pages: [1] Go Down
Author Topic: dealloc question (Read 1403 times)
Full Member
Posts: 118

on: March 15, 2009, 10:02:04 PM

Hey Steve,

I was wondering about your dealloc example in Chapter 8.  Since
-(void) dealoc {
       [origin release];
       return [super dealloc];

is a method in the Rectangle class, do we need to call that method in main to make it work?

Is this some special method that does not need to be called to happen?

Also, I do not understand how synthesizing the accessor methods has an effect on dealloc.

Thanks for your help as always,
Hero Member
Posts: 3114

Reply #1 on: March 16, 2009, 05:43:06 AM

Remember (see the note on p. 179) that the dealloc method is called automatically by the system when the space for an object is to be destroyed.  This normally happens after you release the object.  (As you'll learn in later chapters, dealloc will not be called if the object is referenced someplace else in the program).

For your second question, if you specify either the retain or copy attributes in your @property declaration, the synthesized accesor method will automatically release the old value of the instance variable in the setter method.    As noted in the previous paragraph, this may end up invoking the dealloc method.


Last Edit: March 16, 2009, 05:45:39 AM by skochan Logged
Full Member
Posts: 118

Reply #2 on: March 16, 2009, 09:09:39 PM

OK, I see.  It appears that you go further into detail with retain or copy in the Memory Management chapter.
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.