• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: iPhone: @protocol and @optional
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >iPhone: @protocol and @optional (From: John Michael Zorko <email@hidden>)
 >Re: iPhone: @protocol and @optional (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: iPhone: @protocol and @optional
  • Next by Date: Re: NSDate without time portion
  • Previous by thread: Re: iPhone: @protocol and @optional
  • Next by thread: Resolution Independence
  • Index(es):
    • Date
    • Thread