Amazon.com Widgets Program 7.6, why aFraction is not getting realesed too within For loop?
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 18, 2014, 06:47: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 7 - More on Classes
| | | |-+ Program 7.6, why aFraction is not getting realesed too within For loop?
Pages: [1] Go Down
Print
Author Topic: Program 7.6, why aFraction is not getting realesed too within For loop? (Read 626 times)
xiahou17
Newbie
*
Posts: 1


Email




on: November 28, 2010, 08:03:15 PM

Here is part of Program 7.6 in page 154:

for (i = 1; i <= n; ++i) {
[aFraction setTo: 1 over: pow2];
sum2 = [sum add: aFraction];
[sum release]; // release previous sum
sum = sum2;
pow2 *= 2;
}

sum is getting release because "The old sum is then released" to avoid memory leakage, but why aFraction is not released too with the for loop? Seems it also changes value with every loop.

Thanks in advance to any help.
Last Edit: November 28, 2010, 08:04:51 PM by xiahou17 Logged
skochan
Administrator
Hero Member
*****
Posts: 3114







Reply #1 on: December 17, 2010, 05:32:44 PM

You really must read the stickied topic at the top of this category first, as it goes into a lot of detail on all of this.

Cheers,

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