FROM : Jens Alfke
DATE : Mon Jun 16 20:23:50 2008
On 15 Jun '08, at 5:39 PM, James W. Walker wrote:
> No, the controller does not keep a reference to the task. Why would
> it need to do that in order to "keep it alive"?
Because objects only exist if they have references (i.e. a refcount >
0), and it generally makes your code cleaner if those references
"belong to" other objects, i.e. the typical retained-instance-variable
pattern. While it's possible in a ref-counted environment to have an
object that calls retain and release on itself to manage its own
lifespan, it can be confusing to keep track of. It also has the
distinct problem of not working with real garbage collection — if the
garbage collector sees that nothing else in the app points to your
object, it will dealloc it.
—Jens
DATE : Mon Jun 16 20:23:50 2008
On 15 Jun '08, at 5:39 PM, James W. Walker wrote:
> No, the controller does not keep a reference to the task. Why would
> it need to do that in order to "keep it alive"?
Because objects only exist if they have references (i.e. a refcount >
0), and it generally makes your code cleaner if those references
"belong to" other objects, i.e. the typical retained-instance-variable
pattern. While it's possible in a ref-counted environment to have an
object that calls retain and release on itself to manage its own
lifespan, it can be confusing to keep track of. It also has the
distinct problem of not working with real garbage collection — if the
garbage collector sees that nothing else in the app points to your
object, it will dealloc it.
—Jens
| Related mails | Author | Date |
|---|---|---|
| James W. Walker | Jun 16, 00:20 | |
| Andreas Monitzer | Jun 16, 00:25 | |
| James W. Walker | Jun 16, 00:53 | |
| Hamish Allan | Jun 16, 01:04 | |
| James W. Walker | Jun 16, 02:39 | |
| Jens Alfke | Jun 16, 20:23 | |
| Hamish Allan | Jun 16, 21:52 | |
| Christopher Nebel | Jun 16, 23:14 | |
| James Walker | Jun 16, 23:17 |






Cocoa mail archive

