• 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: run-time list of selectors in protocol?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: run-time list of selectors in protocol?


  • Subject: Re: run-time list of selectors in protocol?
  • From: Damien Bobillot <email@hidden>
  • Date: Fri, 9 Dec 2005 18:09:06 +0100


Le 9 déc. 05 à 17:54, Jeff LaMarche a écrit :

On Dec 9, 2005, at 11:51 AM, William Turner wrote:

Is there a way I can query a protocol at run-time to get a list of the selectors it includes?

On a related note, is there a way to get more detailed information when a class fails to "conformToProtocol"?

I'm having trouble envisioning a situation where you would need to know at runtime what methods a protocol contains. This seems like it's going to be primarily a compile-time issue.

You can always look at the protocol's header files, which you'll find inside the framework that contains it. Although compiled frameworks do not have the source code, they do have the header files, which should list all the required methods. If it's an Apple- supplied protocol, you can also just use XCode's documentation browser or AppKiDo to find out how to conform to the protocol.

I agree with Jeff : needing to access to the list of available methods in often du to a bad code design. In most case, using conformToProtocol: or respondToSelector: in far from sufficient.

However, if you think you are in really special case, look at the Objective-C runtime introspection functions :
http://developer.apple.com/documentation/Cocoa/Reference/ ObjCRuntimeRef/index.html

--
Damien Bobillot

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: run-time list of selectors in protocol?
      • From: William Turner <email@hidden>
References: 
 >run-time list of selectors in protocol? (From: William Turner <email@hidden>)
 >Re: run-time list of selectors in protocol? (From: Jeff LaMarche <email@hidden>)

  • Prev by Date: Re: adding an executable as a resource
  • Next by Date: Re: adding an executable as a resource
  • Previous by thread: Re: run-time list of selectors in protocol?
  • Next by thread: Re: run-time list of selectors in protocol?
  • Index(es):
    • Date
    • Thread