Hello,

I'm trying to get the methods a protocol specifies and just stumbled upon
one problem: the following code returns NULL:

    Protocol *protocol = objc_getProtocol("NSApplicationDelegate");

I saw (
http://stackoverflow.com/questions/10212119/objc-getprotocol-returns-null-for-nsapplicationdelegate)
that the it is because the protocol was not:

    Adopted by a class,
    Or referred to somewhere in source code (using @protocol())

As am doing this at runtime, I cannot use "@protocol()", right?

So I thought I will add the protocol to the class:

    Protocol *protocol = objc_getProtocol("NSApplicationDelegate");
    BOOL class_addProtocol(class, protocol);

The problem, obviously, is that I cannot add a protocol until it been
created and the protocol wont be created until used be a class.

Is there a way to get NSApplicationDelegate protocol besides the
compile-time "@protocol()"?

Also, when I do:

    Protocol *protocol = objc_getProtocol("NSTextViewDelegate");

return the protocol even when I didn't create any textviews...?

PS: To get all the method descriptions of a protocol, do I have to call
four times "protocol_getMethodDescription"?

    protocol_getMethodDescription(p, aSel, NO, NO);
    protocol_getMethodDescription(p, aSel, NO, YES);
    protocol_getMethodDescription(p, aSel, YES, NO);
    protocol_getMethodDescription(p, aSel, YES, YES);
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to