• 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: init method ambiguity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: init method ambiguity


  • Subject: Re: init method ambiguity
  • From: Jonny Taylor <email@hidden>
  • Date: Thu, 4 Nov 2010 13:12:48 +0000

>> One workaround is to include explicit casts like I have shown. However this leaves me wondering whether it goes against convention and/or recommendations to have two init methods with the same name but different parameter types, even for two unrelated different classes (hard to enforce - one could imagine completely different codebases colliding by chance in this respect). Can anybody comment on this?
>
> One question that comes to my mind is whether, given the similarity in
> their names, are your two camera classes really *entirely* unrelated?
> Is there a common base class, or a protocol they could share? Could
> they be made into a class cluster? If so, you could declare your init
> like one of these:
>
>  -(id)initForCamera:(CameraBase*)cam;
>  -(id)initForCamera:(id<CameraProtocol>)cam;

You are right on the mark there - I do in fact have a CameraProtocol defined. However in this case the classes that are being inited are "frame" classes QIFrame and PSFrame. These classes (and only these classes) need to understand the implementation details of individual camera models, and their implementation is a lot simpler if they have access to a pointer to the actual camera subclass._______________________________________________

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

  • Follow-Ups:
    • Re: init method ambiguity
      • From: Sherm Pendley <email@hidden>
References: 
 >init method ambiguity (From: Jonny Taylor <email@hidden>)
 >Re: init method ambiguity (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Re: init method ambiguity
  • Next by Date: Resizable NSTabView
  • Previous by thread: Re: init method ambiguity
  • Next by thread: Re: init method ambiguity
  • Index(es):
    • Date
    • Thread