Re: Exception raised during posting of notification
Re: Exception raised during posting of notification
- Subject: Re: Exception raised during posting of notification
- From: j o a r <email@hidden>
- Date: Mon, 30 May 2005 13:31:41 +0200
On 30 maj 2005, at 13.17, Ondra Cada wrote:
Subscriptions for notifications needs to always be balanced with
an unsubscribe at some later point
... unless the subsribing object stays till the application ends
(=is never deallocated). That is pretty common with controllers,
and since controllers often subscribe to notifications, it is not
exceptional to have a perfectly valid code in which there is a
subscription, but no unsubscription at all.
Of course, what j o a r said is *perfectly* right for anything
which could be deallocated.
My recommendation is usually to design singleton (ie. "immortal")
objects no different from "normal" objects. In other words, let them
have a full fledged dealloc method even if it's never going to be
used. Two reasons:
* It's not that uncommon that you might later change your design, and
turn the singleton object into a non-singleton object. It's easier to
populate the dealloc method while you develop the class, compared
with after the fact.
* If you always write "complete" code (retain - release balanced,
subscribe - unsubscribe balanced, et.c.), it quickly becomes second
nature, and it will be less likely that you forget to do it when it
really matters.
Just my humble opinion...
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden