In the code you've just posted, NSAutoreleasePool is not used in any
way for your string.
The sequence of alloc, init, and release does not use the autorelease
pool since no -autorelease message is ever sent. Instead it does
exactly as written:
1. Creates a new string object with a retain count of 1.
2. Releases the string so it has a retain count of 0.
3. Deallocates the memory used by the string since it has a retain
count of 1.
Mike.
P.S. Normally in Cocoa you use lowercase to start a variable name. i.e.
NSString *line
On 23 Oct 2007, at 18:50, Erfan Aleemullah wrote:
I was wondering how this works and what happens if the retain count
reaches
0 but the object wasn't part of a autorelease pool ?
*Example:*
NS* String Line = [NSString alloc] init];
.. random code ..
[Line release];
Now, what happens if the retain count is 1 and if its 0 for NSString
Line ?
?
How should I use an autorelease pool to actually deallocate the
memory used
by Line ?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com