• 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: Static in Subclasses
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Static in Subclasses


  • Subject: Re: Static in Subclasses
  • From: Jon Gordon <email@hidden>
  • Date: Thu, 27 Mar 2008 21:47:57 -0400


On Mar 27, 2008, at 5:17 PM, email@hidden wrote:


Date: Thu, 27 Mar 2008 14:44:17 -0600
From: Justin Giboney <email@hidden>
Subject: Static in Subclasses
To: Cocoa Developers <email@hidden>
Message-ID:
	<email@hidden>
Content-Type: text/plain;	charset=US-ASCII;	format=flowed;	delsp=yes

I need to create a series of classes that implement the Singleton
design pattern. These classes have a lot of similar methods (I am
trying to create a series of DAOs see: http://en.wikipedia.org/wiki/Data_Access_Object)
.

I was thinking that it would be best to create a super class, and a
series of subclasses to that super class. The problem I am running
upon is that the Singleton pattern requires a static variable.

How can I get a variable that is static to each subclass, but that is
declared in the super class?

for example I tried this.

<snip>

I had a similar problem, and I addressed it by implementing a class cluster in which
each of the private subclasses was a singleton. To handle the static variable
issue, I just created a static NSDictionary in the source file in which the
subclass identifier was the key, and the singleton instance was the value.


Justin, I'll send you my source files privately to avoid making this message too
long, but anyone else who wants to see what I did should feel free to mail me and
ask.


     -Jon

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Prev by Date: Re: Subverting the first responder chain
  • Next by Date: Re: error strings in NSPropertyListSerialization
  • Previous by thread: Re: Static in Subclasses
  • Next by thread: Is @"constantstring" pointer equal to @"constantstring" a guarantee?
  • Index(es):
    • Date
    • Thread