Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
May 23, 2018, 11:53:43 AM *
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
Author Topic: Program 7.6, why aFraction is not getting realesed too within For loop?  (Read 1154 times)
Posts: 1

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


Pages: [1]   Go Up
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 All rights reserved.