• 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: Abstract class with single subclass
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Abstract class with single subclass


  • Subject: Re: Abstract class with single subclass
  • From: Michael Ash <email@hidden>
  • Date: Wed, 27 May 2009 10:51:30 -0400

On Wed, May 27, 2009 at 9:48 AM, Freddie Tilley <email@hidden> wrote:
> If I would want to allocate a class which allocates a single subclass
> instead, to
> hide the class implementation details
>
> would this be the correct way of doing it?
>
> The following code would be in the BaseClass
>
> + (id)allocWithZone:(NSZone*)aZone
> {
>        if ([[self class] isEqualTo:[BaseClass class]])

Oops, I forgot to mention one other thing. This works but is
excessively wordy and strange. In a class method, [self class] is
equivalent to self. -isEqualTo: is a method that exists for
AppleScript support; the proper one to use is -isEqual:. However,
since class equality is always the same as object identity, you don't
need to use a method at all, but can shorten it down to if(self ==
[BaseClass class]).

Mike
_______________________________________________

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

  • Follow-Ups:
    • Re: Abstract class with single subclass
      • From: Seth Willits <email@hidden>
    • Re: Abstract class with single subclass
      • From: Freddie Tilley <email@hidden>
References: 
 >Abstract class with single subclass (From: Freddie Tilley <email@hidden>)

  • Prev by Date: Re: Abstract class with single subclass
  • Next by Date: Re: NSString initWithFormat and stringWith
  • Previous by thread: Re: Abstract class with single subclass
  • Next by thread: Re: Abstract class with single subclass
  • Index(es):
    • Date
    • Thread