Re: method naming
Re: method naming
- Subject: Re: method naming
- From: Charles Steinman <email@hidden>
- Date: Tue, 29 Jul 2008 19:05:17 -0700 (PDT)
--- On Tue, 7/29/08, Torsten Curdt <email@hidden> wrote:
> Class A has method
>
> - (void) something:(Someclass*)s;
>
> Class B has method
>
> - (BOOL) something:(Someclass*)s;
>
> Why on earth am I getting a warning
>
> warning: multiple methods named '-something:'
> found
> using...
> also found...
>
> They are on different objects. Should be obvious there is
> no problem.
> Is this really just a "careful - you sure you picked
> the right one?"
> Or what am I missing?
The compiler doesn't know what class the object belongs to. You're sending the message either to a variable of type id or the result of a method that returned id. The id type can hold any class, so if there are two identically named methods with different signatures (BOOL return type vs. void, for instance), it doesn't have enough information to pick the right signature.
Cheers,
Chuck
_______________________________________________
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