Skip navigation.
 
mlRe: How can an object know when another object has gone away?
FROM : Christopher Nebel
DATE : Mon Jun 16 23:14:47 2008

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, I'd use LBroadcaster and LListener, with the listener 
>>> listening for msg_BroadcasterDied.

>>
>> What about using NSNotificationCenter?

>
> Thanks, it looks like that would work.  Somehow I was under the 
> impression that notifications were, uh, broadcast more broadly than 
> I wanted, but now I see that you can register to receive 
> notifications only for a specific object.


If using the new Objective-C garbage collection is an option, you 
could also use a zeroing weak reference: see <http://developer.apple.com/documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcDesignPatterns.html#//apple_ref/doc/uid/TP40006762-SW10
>


--Chris N.

Related mailsAuthorDate
mlHow can an object know when another object has gone away? James W. Walker Jun 16, 00:20
mlRe: How can an object know when another object has gone away? Andreas Monitzer Jun 16, 00:25
mlRe: How can an object know when another object has gone away? James W. Walker Jun 16, 00:53
mlRe: How can an object know when another object has gone away? Hamish Allan Jun 16, 01:04
mlRe: How can an object know when another object has gone away? James W. Walker Jun 16, 02:39
mlRe: How can an object know when another object has gone away? Jens Alfke Jun 16, 20:23
mlRe: How can an object know when another object has gone away? Hamish Allan Jun 16, 21:52
mlRe: How can an object know when another object has gone away? Christopher Nebel Jun 16, 23:14
mlRe: How can an object know when another object has gone away? James Walker Jun 16, 23:17