You can get all the methods declared in the protocol using protocol_copyMethodDescriptionListthat returns a pointer to objc_method_descriptionstructs.
objc_method_descriptiondefined in objc/runtime.h:
struct objc_method_description {
SEL name;
char *types;
};
To find out if class instances respond to a selector instancesRespondToSelector:
Leaving you with this function:
BOOL ClassImplementsAllMethodsInProtocol(Class class, Protocol *protocol) {
unsigned int count;
struct objc_method_description *methodDescriptions = protocol_copyMethodDescriptionList(protocol, NO, YES, &count);
BOOL implementsAll = YES;
for (unsigned int i = 0; i<count; i++) {
if (![class instancesRespondToSelector:methodDescriptions[i].name]) {
implementsAll = NO;
break;
}
}
free(methodDescriptions);
return implementsAll;
}
source
share