| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Am Mittwoch, 30.07.03 um 01:13 Uhr schrieb John Randolph:
On Tuesday, July 29, 2003, at 11:23 AM, Nat! wrote:Autorelease pools have some clear semantics. Every object added to
an autorelease pool gains a property, a guaranteed minimum lifetime.
Umm, no.
An object added to an autorelease pool is going to get a -release
message whenever the pool gets released, and that's all. The act of
adding it to the pool has no effect of guaranteeing a minimum >
lifetime.
-jcr
ok, I should have explicitily stated the assumption that the object is
added retained.
But with my answer I am obscuring my own point, that adding it retained
to the pool does guarantee a minimum lifetime. As John states "An
object added to an autorelease pool is going to get a -release message
whenever the pool gets released". That's exactly the minimum lifetime.
It can be longer, but it can't be less.
And adding it non-retained and not crashing is a trick you must show me
as
s = [[NSString alloc] initWithFormat:@"My retain count is 1"]
[s autorelease]; // yes its retained
[s release]; // bad idea
In this example ownership is transferred to the autorelease pool. s can
not die earlier than the enclosing autorelease pool.
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.