I found that I could do such things in objc:
Protocol* aProtocol = @protocol(NSObject);
but what is this technique used for?
I found that I could do such things in objc:
Protocol* aProtocol = @protocol(NSObject);
but what is this technique used for?
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];
what is use of Formal Protocol Object
You can use it to check if an object conforms to a protocol.
[anotherObject conformsToProtocol:aProtocol];