I, too, am trying to:
Protocol *protocol = objc_getProtocol("NSApplicationDelegate");
as seen here:
objc_getProtocol() returns NULL for `NSApplicationDelegate"?
The accepted answer says that it is returning NULL because I haven't done one of:
- Adopted by a class,
- Or referred to somewhere in source code (using
@protocol()
)
Now, @protocol
is out of question because I run this at runtime, right? So that leaves me with adding the protocol to the class, with BOOL class_addProtocol(Class cls, Protocol *protocol)
But how can I add a protocol to a class when the protocol was not yet created?
In other words, it seems I have to do:
Protocol *protocol = objc_getProtocol("NSApplicationDelegate");
BOOL class_addProtocol(class, protocol);
But the first line returns NULL...