Re: Getting NSApplicationDelegate protocol
Re: Getting NSApplicationDelegate protocol
- Subject: Re: Getting NSApplicationDelegate protocol
- From: Ken Thomases <email@hidden>
- Date: Fri, 06 Jul 2012 04:56:33 -0500
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 (email@hidden)
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:
This email sent to email@hidden