Re: split up alloc and init?
Re: split up alloc and init?
- Subject: Re: split up alloc and init?
- From: Bill Bumgarner <email@hidden>
- Date: Mon, 11 Feb 2008 10:06:08 -0800
On Feb 11, 2008, at 12:04 AM, John Terranova wrote:
The self = [super init] discussion is interesting. Here is
something related that I came across just before the [super init]
discussion started. Basically, is it safe to split up alloc and init?
It is sometimes (keeping in mind that the return value of -init may be
different than what you got from +alloc), but not always, safe and the
case by case answer is entirely an implementation detail.
Some classes will return a proxy from +alloc that effectively does
absolutely nothing -- and complains very loudly if anything else is
attempted -- until an appropriate -init... is called which then
returns an instance of the most appropriate class given context within
the initializer.
Given that it is your own class, you can ensure that it behaves
correctly in such a situation. I would recommend against doing so
simply because it is a pattern that is rarely used and, when used, is
often the source of bugs that can be quite baffling.
b.bum
_______________________________________________
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