Am Mi,20.08.2008 um 15:37 schrieb Joan Lluch (casa):



Am Mo,18.08.2008 um 20:14 schrieb Andy Lee:


Since the observed object (maybe notification center) will still hold a reference to the observing object, there is a problem. The *observer* will not be freed, if the observed is still living. Obviously you have a problem using GC, for example if you have an observing window and an observed model instance. The model probably lives longer than the window. (Think of info windows …)

This seems to be the reason for the weak reference using GC.

I've been reading this thread and I don't understand it in the case of GC. Why don't you still have to remove the observer from the notification center when you are not longer using it. Even if it is held as a weak reference, it will still remain registered for receiving notifications, so what when the observer is eventually collected, won't the notification center continue sending messages to the observer as long as it remains registered to receive them?, Please clarify.
First I want to say, that I'm happy to have a thread on this list, which is not related to a concrete problem, but discusses a design. I like that. :-)

Second: As you read, *I* would prefer to unregister the observer explicitly. You can do this in -finalize, but I do not have to repeat the design problems with finalization. *I* wanted a delegate method or a defined method to be overwritten in a subclass (I mentioned -close) to do it explicitly, *before* destroying the object. You ask the wrong person …

Third, to your question: Weak references in GC – they have nothing to do with "retainless" weak references using RC – are nullified automatically. If you use GC the weak collection should be modified appropiate by the collector itself. So this might be no problem. (I didn't test it, because it is not my idea.)

Anyway, as said: *I do not* want to handle the unregister this way. I want to handle it explicitly, but found no -willClose method or something like this. (You cannot relay on -close, as I said in the OP.)

Cheers,
Amin



Joan Lluch



Amin Negm-Awad
[EMAIL PROTECTED]




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to