• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: super constructor encapsulation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >super constructor encapsulation (From: "Ahmet Taha Sakar" <email@hidden>)
 >Re: super constructor encapsulation (From: Jim Correia <email@hidden>)
 >Re: super constructor encapsulation (From: "Michael Novak" <email@hidden>)

  • Prev by Date: Re: super constructor encapsulation
  • Next by Date: Re: super constructor encapsulation
  • Previous by thread: Re: super constructor encapsulation
  • Next by thread: Re: super constructor encapsulation
  • Index(es):
    • Date
    • Thread