> This compiles and runs fine, even though MyClass never adopted the protocol
> Unadopted. It take it that by casting mc to an id, I cause the compiler to
> grasp at the only signature for "testing" that it knows about, namely the
> one in the protocol. So it happily uses that signature without complaint,
> and at runtime the correct message is sent to the MyClass instance.

I noticed this, but I assume that by casting it to an id you are discarding the 
protocol conformance. I'd always thought protocol conformance was just to have 
the compiler warn you if you hadn't implemented a particular method. Doesn't it 
only get checked at runtime if conformsToProtocol: is called on it?
By having an id variable, the compiler thinks it can accept any message, and if 
the object can respond to that message at runtime, it's all fine.

So... maybe (d) :)

_______________________________________________

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]

Reply via email to