Re: The Power of Init
Re: The Power of Init
- Subject: Re: The Power of Init
- From: j o a r <email@hidden>
- Date: Tue, 20 Dec 2005 21:52:21 +0100
On 20 dec 2005, at 21.38, Jonathan Faulkenberry wrote:
Yet another newbie question, why does Apple recommend (through the
code completion function) that may init function should include a
if (self != nil) statement? How could self be equal to nil anyway?
It usually looks something like this:
if (nil != (self = [super init]))
// do stuff
The point here being that one of your superclasses could decide that
it's not a good time to create a new instance (bad parameters would
be the most likely cause) and as a result return nil from init. As a
subclass you should look out for that, and only perform
initialization code if the superclass initialized successfully.
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden