• 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: Class Factory Methods?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Class Factory Methods?


  • Subject: Re: Class Factory Methods?
  • From: Kyle Sluder <email@hidden>
  • Date: Mon, 22 Jun 2009 12:19:52 -0700

On Mon, Jun 22, 2009 at 12:02 PM, Chunk 1978<email@hidden> wrote:
> "new", "alloc", initWithFormat" (or "stringWithFormat") are class
> factory methods that are declared methods inherited by my custom
> classes, i guess somewhere in NSObject?

No.  +alloc is a class method that creates a new instance.
-initWithFormat: is an initializer.  +new is a shortcut for saying
[[Foo alloc] init].  +stringWithFormat: is a convenience constructor
that returns an unowned reference, and is therefore similar to doing
[[[NSString alloc] initWithFormat:...] autorelease].

Please review the conceptual documentation, particularly the
introduction to Objective-C and the Memory Management Guide.

--Kyle Sluder
_______________________________________________

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

References: 
 >Class Factory Methods? (From: Chunk 1978 <email@hidden>)

  • Prev by Date: Class Factory Methods?
  • Next by Date: Re: Class Factory Methods?
  • Previous by thread: Class Factory Methods?
  • Next by thread: Re: Class Factory Methods?
  • Index(es):
    • Date
    • Thread