On Thu, Nov 4, 2010 at 8:23 AM, Jonny Taylor <[email protected]> wrote: > > This leads me to believe that what I am writing is not actually doing > anything wrong, and the compiler warning is associated with the fact that > [MyClassA alloc] returns a plain id leaving the compiler to do some deducing > about what the type actually is. This, combined with the confusion of having > two methods (for different classes) with the same name but different > parameter types, seems to be confusing things.
Exactly. > 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; sherm-- -- Cocoa programming in Perl: http://camelbones.sourceforge.net _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
