Re: Protocols and Classes
Re: Protocols and Classes
- Subject: Re: Protocols and Classes
- From: j o a r <email@hidden>
- Date: Fri, 7 Nov 2003 07:39:19 +0100
On 2003-11-07, at 00.05, Mike R. Manzano wrote:
If I have a class:
Class *myClass = ... ;
How can I determine if myClass adopts a protocol pProtocol?
I know I can get the name of the class using NSStringFromClass(), but
how about a list of the formal protocols it adopts? Or do I have to
test to see if it responds to the selectors that I need?
If the class formally conforms to a protocol you can check for protocol
conformance in the usual way:
BOOL doesConform = [myClass conformsToProtocol: @protocol(pProtocol)];
If it is just an informal protocol, then you need to check the method
selectors individually.
It's all documented here:
<http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/
index.html>
j o a r
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.