0

I found that I could do such things in objc:

Protocol* aProtocol = @protocol(NSObject);

but what is this technique used for?

CarmeloS
  • 7,868
  • 8
  • 56
  • 103
  • To do this: http://stackoverflow.com/questions/3436257/objective-c-runtime-best-way-to-check-if-class-conforms-to-protocol – kennytm Nov 17 '11 at 10:45

2 Answers2

0

You could have, for example, a container that offers a service to check that all of its contents conform to a protocol.

Protocol *contentProtocol;

- (void)setContentProtocol:(Protocol *)proto;

Then the user of the container could call:

[container setContentProtocol:@protocol(MyProtocol)];

And somewhere in the container the check could be made:

[[item class] conformsToProtocol:contentProtocol];
Arkku
  • 41,011
  • 10
  • 62
  • 84
0

what is use of Formal Protocol Object
You can use it to check if an object conforms to a protocol.

[anotherObject conformsToProtocol:aProtocol];
Community
  • 1
  • 1
Parag Bafna
  • 22,812
  • 8
  • 71
  • 144