On Apr 26, 2010, at 1:01 PM, Matt Neuburg wrote:

"Methods in different classes that have the same selector (the same name)
must also share the same return and argument types. This constraint is
imposed by the compiler..."

It's more like "should", and the reason is because of the ambiguity of sending the message when the receiver type isn't known. In my experience you just get a warning when the parser has seen two incompatible declarations of the same selector and tries to resolve its use in a message to 'id'.

   MyClass* thing = [[MyClass alloc] init];
   NSString* s = @"Howdy";
   [(id)thing tryme: s];

This, too, compiles with no problem. Why is the compiler not complaining that tryme: is ambiguous? Isn't that what it's supposed to do? (That is why I cast to an id, so that the compiler wouldn't be able to resolve tryme:.)

I would also expect a warning there. Had the parser seen both MyClass and MyClass2's interfaces by that point, i.e. did you #import both of their headers?

—Jens_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to