• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Singletons?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: Singletons? (From: Gregory Weston <email@hidden>)

  • Prev by Date: Genie effect for Cocoa windows
  • Next by Date: Re: [Q] large flat files usage (OT Humor)
  • Previous by thread: Re: Singletons?
  • Next by thread: NSOpenGLView weird scrolling behavior ?
  • Index(es):
    • Date
    • Thread