id <YourProtocol> delegate (which is used to refer to the protocol)?
I mentioned an Apple DOC spokesperson and found a simple example to reference other protocols in the protocol:
where protocol B is declared as follows:
#import "Ah" @protocol B - bar:(id <A>)anObject; @end
Note that using the @protocol directive this way simply tells the compiler that B is a protocol that will be defined later. It does not import the interface file where protocol B is defined.
And here are a few more things you would like to learn about protocol :
In many ways, protocols are similar to class definitions. They declare methods, and at run time they are represented as class objects by class instances and protocols by protocol instances. Like class objects, protocol objects are created automatically from the definitions and declarations found in the source code and used by the runtime system. They are not allocated or initialized in the program source code.
The source code can refer to the protocol object using the @protocol () directive - the same directive that declares the protocol, except that it has a set of end brackets here. The brackets enclose the protocol name:
Protocol *myXMLSupportProtocol = @protocol(MyXMLSupport);
This is the only way that the source code can call the protocol object. Unlike the class name, the protocol name does not mean an object, except inside @protocol ().
And what else, protocol can be checked to see if the object conforms to the protocol by sending it a message conformsToProtocol: ::
if ( ! [receiver conformsToProtocol:@protocol(MyXMLSupport)] ) {
The correspondence of ToProtocol: test is similar to responsesToSelector: test for a single method, except that it checks if the protocol has been accepted (and, presumably, all the methods that it declares), and not just whether one particular method has been implemented. Since it checks all the methods in the protocol, ToProtocol matches: it may be more efficient than responding to a request:
Matching ToProtocol: test is also similar to the isKindOfClass: test test, except that it tests a type based on the protocol and not a type based on the inheritance hierarchy.