Re: Automagic instantiation of singletons? (Christian Brunschen)
Re: Automagic instantiation of singletons? (Christian Brunschen)
- Subject: Re: Automagic instantiation of singletons? (Christian Brunschen)
- From: Theo Vosse <email@hidden>
- Date: Fri, 18 Nov 2005 18:00:42 +0100
The common way in C++ for instantiating singletons is
class Singleton
{
public:
Singleton()
{
// Instantiation code here
}
};
static Singleton my_singleton_instantiation_dont_touch;
The static variable will cause Singleton::Singleton() to be called
before main() is executed. You can mix C++ and Objective-C code
without problems. There are (AFAIK) only problems with this trick
when loading dynamic libraries in a multi-threaded context.
A more Cocoa-like way of doing it might be to use +initialize.
_______________________________________________
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