I know this must be a very basic question, but I'm having trouble understanding something I read in the Objective-C book. I have a lot of background in Visual Basic and RealBasic, so maybe that's getting in the way. And I've been reading various articles and searching for the last hour but haven't found anything that really helps.
Regarding memory management, what does the release command really do? I'm looking at a loop in this snippet
pow2 = 2;
for (i=1; i<=n; ++i) {
[aFraction setTo: 1 over: pow2];
sum2 = [sum add: aFraction];
[sum release]; // release previous sum
sum = sum2;
pow2 *= 2;
}
What confuses me is the reference to sum right after it's been released. When I first read the chapter, the idea associated it with is that the object has been "released" and isn't available anymore -- but then the very next line uses it again. But if the object is still hanging around after the Release, then what did the Release do/accomplish?
Chuck
Regarding memory management, what does the release command really do? I'm looking at a loop in this snippet
pow2 = 2;
for (i=1; i<=n; ++i) {
[aFraction setTo: 1 over: pow2];
sum2 = [sum add: aFraction];
[sum release]; // release previous sum
sum = sum2;
pow2 *= 2;
}
What confuses me is the reference to sum right after it's been released. When I first read the chapter, the idea associated it with is that the object has been "released" and isn't available anymore -- but then the very next line uses it again. But if the object is still hanging around after the Release, then what did the Release do/accomplish?
Chuck