Re: Class Factory Methods?
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