Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
December 16, 2017, 09:23:13 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: 7.6 sum2 release??  (Read 1917 times)
Bertus
Newbie
*
Posts: 20


'Audaces fortuna iuvat'


WWW Email
« on: May 19, 2011, 07:24:42 AM »

 Huh

In exercise 7.6 sum2 isn't released, why is that??

It confuses me, because in prog 7.5 the resultFraction seems to be of the same kind (not allocated/initiated, later allocated by the add: method) but this resultFraction DOES get released at the end, what's the difference between these variables??
And foremost: what's the difference in releasing them??

Bertus
 Huh
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114



« Reply #1 on: May 19, 2011, 01:22:41 PM »

Please see this post, which contains a detailed discussion on this topic: http://classroomm.com/objective-c/index.php?topic=56.0

Cheers,

Steve
Logged
Bertus
Newbie
*
Posts: 20


'Audaces fortuna iuvat'


WWW Email
« Reply #2 on: May 19, 2011, 01:53:59 PM »

So, if i understand correctly the one and only reason why sum2 isn't released is because sum points to the same memory location, which can only be released once? This pointing to the same location is done by sum = sum2 i am guessing?

I'm getting close to understanding....i want to compliment you on your book, i bought it a few years ago, but never started reading because of this enormous amount of 624 pages(!). Since i've been trying to read a lot of books on programming, i have to tell you that this is one of the most compreehensive books on programming, even for non-english natives!

 Grin

Greetings from Holland!

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



« Reply #3 on: May 19, 2011, 01:59:05 PM »

Bertus,

Yes, you are correct; you can't over-release the object. 

Thanks for the compliments.  It is a large book, but there's a lot of ground to cover.  I like to be more complete in covering the material, and not give  a cursory treatment for such a complex subject.

Good luck!

Steve
Logged
Bertus
Newbie
*
Posts: 20


'Audaces fortuna iuvat'


WWW Email
« Reply #4 on: May 19, 2011, 11:21:07 PM »

It might be a good idea to meantion that fact in the book (future versions)

Bertus

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



« Reply #5 on: May 20, 2011, 10:41:42 AM »

The new edition does have a more detailed discussion on this example, based on the feedback from the forum.

Cheers,

Steve
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.