Re: Is Apple's singleton sample code correct?
Re: Is Apple's singleton sample code correct?
- Subject: Re: Is Apple's singleton sample code correct?
- From: Andreas Mayer <email@hidden>
- Date: Tue, 29 Nov 2005 20:03:04 +0100
Am 29.11.2005 um 19:05 Uhr schrieb David Gimeno Gost:
Yet some people have gone as far as saying that the functionality
that everyone would put there for any other object, should be put
somewhere else for singletons, just because -dealloc has been
prevented from ever being called for no apparent reason.
AFAIK it's not only singletons where you can't depend on dealloc
being called before the application quits.
Therefore it might be necessary to listen to the appropriate
notifications to do your cleanup; singleton or not.
To be honest, I really don't understand this discussion. No matter
which exact implementation you choose - if the singleton is used as
such, each one works.
I'm generally against preventing the user of my code from
deliberately making mistakes; he might actually have a reason to do
what I would have seen as an error. So I usually go with the simplest
solution.
On the other hand I'm not writing system-frameworks, which obviously
should be more robust. And there might well be reasons to guard
singletons from being deallocated by application developers. I think
that's a valid reason to write more elaborate and more restrictive
singleton code.
Just use whatever works for you.
Andreas
_______________________________________________
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