• 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: Design Paterns: +/- Initializers and Subclassing (Solved)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Design Paterns: +/- Initializers and Subclassing (Solved)


  • Subject: Re: Design Paterns: +/- Initializers and Subclassing (Solved)
  • From: Christopher J Kemsley <email@hidden>
  • Date: Mon, 3 Aug 2009 01:13:07 -0700

Oh yeah - I thought I did that once and it didn't work... Though, now that I think about it, I think I did it the other way in the past (used self in a +method to refer to a newly created object)

So, in all reality, the +method could be boiled down to:

[self.new autorelease] ;

since

self.new  =  MyClass.new  =  [MyClass new]  =  [ [self alloc] init ]

Thanks for clearing that up!



On Aug 2, 2009, at 10:34 PM, Quincey Morris wrote:

On Aug 2, 2009, at 22:26, Quincey Morris wrote:

	return [ [ [[self class] alloc] init ] autorelease ] ;

('self' refers to the class object because this is a class method)

Doh, if that's true, then:

	return [ [ [self alloc] init ] autorelease ] ;

should be good enough. (IIRC, [self class] == self when self is a class, but I always confuse myself with the class versions of methods, sorry.)


_______________________________________________

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

_______________________________________________

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: Design Paterns: +/- Initializers and Subclassing (Solved)
      • From: Kyle Sluder <email@hidden>
References: 
 >Design Paterns: +/- Initializers and Subclassing (From: Christopher J Kemsley <email@hidden>)
 >Re: Design Paterns: +/- Initializers and Subclassing (From: Quincey Morris <email@hidden>)
 >Re: Design Paterns: +/- Initializers and Subclassing (From: Quincey Morris <email@hidden>)

  • Prev by Date: text control for keyboard shortcut input?
  • Next by Date: Re: Design Paterns: +/- Initializers and Subclassing (Solved)
  • Previous by thread: Re: Design Paterns: +/- Initializers and Subclassing
  • Next by thread: Re: Design Paterns: +/- Initializers and Subclassing (Solved)
  • Index(es):
    • Date
    • Thread