Re: iPhone: @protocol and @optional
Re: iPhone: @protocol and @optional
- Subject: Re: iPhone: @protocol and @optional
- From: John Michael Zorko <email@hidden>
- Date: Tue, 05 Jan 2010 11:20:25 -0800
Mike et al,
OK, I get it -- @optional in a @protocol is kind of like #pragma warning:XXXX in (MS) C++ in that it just tells the compiler to not generate specific warnings, in this case warnings about a class that doesn't fully implement the protocol. I thought it would automatically call -respondsToSelector, but I understand that that's runtime behavior, and the protocol doesn't alter what the object does in the runtime. Thanks, all!
Regards,
John, who loves it when he learns something and can verify it himself) :-)
On Jan 5, 2010, at 11:06 AM, Mike Abdullah wrote:
> Protocols cannot decide or change behaviour of an object. Instead, it is up to the object in question to adopt the protocol appropriately. Declaring methods as @optional just means that you have a choice whether to implement or not. Anyone wanting to call the method should first check if its implemented with -respondsToSelector:
_______________________________________________
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