Re: How can an object know when another object has gone away?

2008-06-16 Thread Jens Alfke
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

Re: How can an object know when another object has gone away?

2008-06-16 Thread Hamish Allan
On Mon, Jun 16, 2008 at 1:39 AM, James W. Walker [EMAIL PROTECTED] 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 that's how memory management works. *Something* needs to keep a reference to your NSTask,

Re: How can an object know when another object has gone away?

2008-06-16 Thread Christopher Nebel
On Jun 15, 2008, at 3:53 PM, James W. Walker wrote: On Jun 15, 2008, at 3:25 PM, Andreas Monitzer wrote: On Jun 16, 2008, at 00:20, James W. Walker wrote: Is there a standard Cocoa design pattern or idiom to have an object find out when another object has been destroyed? In PowerPlant,

Re: How can an object know when another object has gone away?

2008-06-16 Thread James Walker
Hamish Allan wrote: On Mon, Jun 16, 2008 at 1:39 AM, James W. Walker [EMAIL PROTECTED] 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 that's how memory management works. *Something* needs to keep a reference

How can an object know when another object has gone away?

2008-06-15 Thread James W. Walker
Is there a standard Cocoa design pattern or idiom to have an object find out when another object has been destroyed? In PowerPlant, I'd use LBroadcaster and LListener, with the listener listening for msg_BroadcasterDied. Here's my specific situation. I have several controllers that can

Re: How can an object know when another object has gone away?

2008-06-15 Thread Andreas Monitzer
On Jun 16, 2008, at 00:20, James W. Walker wrote: Is there a standard Cocoa design pattern or idiom to have an object find out when another object has been destroyed? In PowerPlant, I'd use LBroadcaster and LListener, with the listener listening for msg_BroadcasterDied. What about using

Re: How can an object know when another object has gone away?

2008-06-15 Thread James W. Walker
On Jun 15, 2008, at 3:25 PM, Andreas Monitzer wrote: On Jun 16, 2008, at 00:20, James W. Walker wrote: Is there a standard Cocoa design pattern or idiom to have an object find out when another object has been destroyed? In PowerPlant, I'd use LBroadcaster and LListener, with the listener

Re: How can an object know when another object has gone away?

2008-06-15 Thread Hamish Allan
On Sun, Jun 15, 2008 at 11:20 PM, James W. Walker [EMAIL PROTECTED] wrote: Here's my specific situation. I have several controllers that can create tasks, using an NSTask wrapper based on the Moriarty sample. When a task completes, it sends a message to the controller that created it. If

Re: How can an object know when another object has gone away?

2008-06-15 Thread James W. Walker
On Jun 15, 2008, at 4:04 PM, Hamish Allan wrote: On Sun, Jun 15, 2008 at 11:20 PM, James W. Walker [EMAIL PROTECTED] wrote: Here's my specific situation. I have several controllers that can create tasks, using an NSTask wrapper based on the Moriarty sample. When a task completes, it