Re: super constructor encapsulation
Re: super constructor encapsulation
- Subject: Re: super constructor encapsulation
- From: "Michael Novak" <email@hidden>
- Date: Fri, 13 Apr 2007 12:42:38 -0400
to clarify..... if depth is not given a value by the call default it to 0 or
nil.
cheers,
mike
On 4/13/07, Michael Novak <email@hidden> wrote:
i think you are better off giving depth a nil or 0 value upon
initializing. That should take care of the depth issue.
cheers,
mike
On 4/13/07, Jim Correia <email@hidden> wrote:
>
> On Apr 13, 2007, at 12:13 PM, Ahmet Taha Sakar wrote:
>
> > I create the instance with
> > ClassA foo = [[ClassB alloc] initWithHeight:10 width:20 depth:30];
> >
> > I have seen that
> > ClassA foo = [[ClassB alloc] initWithHeight:10 width:20];
> > also works, which is the constructor for ClassA, but I dont want to
> > allow
> > this. I want to make it so that if one wants to initiate ClassB
> > they have
> > to use it's own constructor with depth parameter.
>
> In Objective-C, they are called initializers, not constructors.
>
> Objective-C is dynamically dispatched; you can't enforce this at
> compile time.
>
> What you can do is
>
> - document that -initWithHeight:width:depth: is the designated
> initializer and should/must be used
> - override -initWithHeight:width: to assign some reasonable default
> to depth, or
> - override -initWithHeight:width: to raise an exception saying that
> the designated initializer must be used
>
> Jim
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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