Am Mo,18.08.2008 um 17:37 schrieb Michael Ash:
On Mon, Aug 18, 2008 at 5:59 AM, Negm-Awad Amin <[EMAIL PROTECTED]
> wrote:
Hi,
for some teaching reasons I have a document class, which observes a
notification. Of course I have to unobserve this notification, when
the
document is closed. Doing this in -dealloc is no good design
(fuunctional
overhead in -dealloc, garbage collection …).
There's nothing wrong with doing it in -dealloc, and in fact this is
the standard way to do it. Overhead is not a problem. That code has to
run *sometime*, and -dealloc is not in anybody's critical path the way
-finalize is. Garbage collection is not a problem, because
notification observers are held with weak references in a GC
Argh, yes, I forgot this.
environment, so you don't need to manually unobserve at all. Also note
that it's pretty rare and undesirable to write dual-mode code. If
you're running under GC, just forget about unobserving. If you're not,
then forget about problems with GC.
Thanks a lot!
With the fact above, -dealloc seems to be a nice place, because it is
*not* executed running garbage collection.
But anyway I do not think, that doing something else then memory
management in -dealloc is good design. Normally I unregister
observation in delegate methods like -applicationWillTerminate:.
Mike
_______________________________________________
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/negm-awad%40cocoading.de
This email sent to [EMAIL PROTECTED]
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]