Re: run-time list of selectors in protocol?
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