Re: Multiple methods named...
Re: Multiple methods named...
- Subject: Re: Multiple methods named...
- From: Uli Kusterer <email@hidden>
- Date: Sat, 16 Feb 2013 11:18:49 +0100
Name them rootA and rootB instead of rootObject? (i.e. if the roots' classes are NSWindshieldWiper and NSGearShift, call them rootWiper and rootGearshift, or so) Or if the two methods are supposed to be interchangeable, specify their common base class or protocol as the return type, or id if you must.
If you really must live with identical names (it's bad design, but sometimes you're using third-party libraries that you can't change), typecast the receiver. But that doesn't seem to be your case, as you're using them interchangeably. So just add a common base class or protocol that both ClassA and ClassB implement that has a rootObject method that returns a common base class or protocol of RootA and RootB.
If ClassA and RootA as well are actually identical, you could probably also use instancetype. (good summary here: http://nshipster.com/instancetype/)
In anyway, "rootObject" is a bad name (you can see it's an object from the context, much better to be more concrete and call it rootWiper or whatever.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.masters-of-the-void.com
On 16.02.2013, at 10:31, Gerriet M. Denkmann <email@hidden> wrote:
> ClassA has a method:
> -(RootA *)rootObject;
>
> ClassB has a method:
> -(RootB *)rootObject;
>
>
> id someObject;
>
> if ( something )
> {
> someObject = instance of ClassA;
> }
> else
> {
> someObject = instance of ClassB;
> }
>
> id someRoot = [ someObject rootObject ];
>
> Here the compiler complains: "Multiple methods named 'rootObject' found".
> What can I do to get rid of this warning? (Other than switching the warning off?)
>
> Gerriet.
>
> 10.8.2, Xcode 4.6
>
>
> _______________________________________________
>
> 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
_______________________________________________
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