Amazon.com Widgets Chapter 8 Help - Overriding The Dealloc Method
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 23, 2013, 04:45:27 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
| | | |-+  Chapter 8 Help - Overriding The Dealloc Method
Pages: [1]   Go Down
Print
Author Topic: Chapter 8 Help - Overriding The Dealloc Method  (Read 532 times)
JTMontana
Newbie
*
Posts: 2


Email




« on: June 10, 2009, 04:56:40 PM »

Hi,

I tried to override the dealloc method in my Rectangle class, everything seems to work fine until i release the Rectangle.  Any code after it is released is not executed and the program does not exit.  Not sure where I went wrong here.  See attachments for code.

Thanks,
JT
Logged
skochan
Administrator
Hero Member
*****
Posts: 3104







« Reply #1 on: June 10, 2009, 08:46:20 PM »

JT,

Look at your setOrigin: method: you are not copying the x, y coordinates of pt into origin.  Instead, you are assigning origin to point to the same (x,y) coordinate pair as the argument (pt) to the method (effectively losing the pointer to the newly allocated XYPoint object).  That's a complex topic, so let me know if you need further explanation, or read the stickied topic on Program 7.5-7.6 for a similar explanation applied to Fraction objects.

Cheers,

Steve Kochan
Logged
JTMontana
Newbie
*
Posts: 2


Email




« Reply #2 on: June 10, 2009, 10:04:36 PM »

I see what I did now, I didn't realize that setting the two XYpoints equal to each other would only make them point to the same location in memory.  Everything is working smoothly now.

Thanks again,

JT
Logged
Pages: [1]   Go Up
Print
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.