Re: Singletons?
Re: Singletons?
- Subject: Re: Singletons?
- From: Michael Gersten <email@hidden>
- Date: Thu, 27 Jun 2002 18:00:48 -0700
Here's a different idea on implementing singletons. It works for classes that descend directly from NSObject.
1. Have your class's 'alloc' method return self.
2. Implement all of the methods as class methods, instead of instance methods.
Result? You create objects the same way -- [[MyClass alloc] init]
But all of the special casing needed to support singletons is a single line in alloc.
Michael
--
I am a Mac 10-Cocoa/WOF/EOF developer, and I'm available for hire. Please contact me at michael-job @ stb.nccom.com if interested. Resume at
http://resumes.dice.com/keybounce
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.