Re: designated initializer conventions
Re: designated initializer conventions
- Subject: Re: designated initializer conventions
- From: j o a r <email@hidden>
- Date: Sun, 30 Jan 2005 13:54:33 +0100
On 2005-01-30, at 11.29, Mike Bolton wrote:
What confuses me is that the above initializer sends the initWithFrame
to self, rather than super.. That would lead me to believe that
initWithFrame is the designated initializer for the class (unless this
is a typo and the initWithFrame should've been sent to super). In
order to conform with the rules mentioned in the previous paragraph,
shouldn't the class implement initWithFrame, which would simply call
"if (self = [super initWithFrame...]", or is this being overly
pedantic, and unnecessary, given that the designated initializer of
the subclass is the same as the superclass, in which case you don't
need to the subclass to override it.
Two things:
* If you don't implement "-initWithFrame:" in your subclass, there is
of course no functional difference between calling [self initWithFrame:
xxx] and [super initWithFrame: xxx]. It might however make a difference
for someone reading the code, to better understand your intentions, if
you call super.
* You need to keep in mind that you can change the designated
initializer when you create a subclass. As soon as you have made sure
to call the designated initializer of your superclass in the proper
places in the implementation of your subclass, you can then document
that your subclass has a different designated initializer than your
superclass.
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