On Jul 6, 2012, at 3:30 AM, ecir hana wrote:

> 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?

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

No.  The run-time information about the protocol is obtained from information 
that would have to have been baked into the executable at build time.


> Also, when I do:
> 
>    Protocol *protocol = objc_getProtocol("NSTextViewDelegate");
> 
> return the protocol even when I didn't create any textviews...?

You have presumably loaded AppKit, and AppKit does have the protocol details 
for NSTextViewDelegate baked into it, because it includes classes which adopt 
it and/or code which uses @protocol(NSTextViewDelegate).

Regards,
Ken


_______________________________________________

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