Well, even simpler, you could just use C without fancy singletons, as in: Debug *gDebug = nil;
int main(int argc, char *argv[]) { gDebug = [[Debug alloc] init]; return NSApplicationMain(argc, (const char **) argv); } Then in any file where you want to use it, put "extern Debug *gDebug;". Or even just include that line at the end of Debug.h. I toss this out just to remind you that Objective-C includes C, so you shouldn't forget C techniques. Or, alternatively, if you don't really know C, you should try to find some time to learn it. For instance, Objective-C includes no specific way to declare a global variable simply because C already does so. Of course this code does not necessarily *prevent* you from making multiple Debug instances, but neither does the code Graham posted if you try to call [Debug sharedDebug] from multiple threads. To really prevent it, if necessary, for a shared library perhaps, takes a bit more work. But if it's your own class, it might be good enough to just have a "don't do that" attitude, (or a check in Debug -init that throws an exception) ;-) -- Scott Ribe scott_r...@killerbytes.com http://www.killerbytes.com/ (303) 722-0567 voice _______________________________________________ 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 arch...@mail-archive.com