Re: Getting NSApplicationDelegate protocol
Re: Getting NSApplicationDelegate protocol
- Subject: Re: Getting NSApplicationDelegate protocol
- From: Ken Thomases <email@hidden>
- Date: Fri, 06 Jul 2012 23:30:19 -0500
On Jul 6, 2012, at 1:01 PM, Stephen J. Butler wrote:
> On Fri, Jul 6, 2012 at 4:35 AM, ecir hana <email@hidden> wrote:
>> Sorry I should've said that before: no, I'm on 10.6.
>>
>> But thanks for the reply!
>
> You're positive you're linking against the 10.6 SDK? Even if you're on
> 10.6 you might be linking against the 10.5 SDK and that would explain
> your problem perfectly.
It wouldn't matter. If you have the "class-dump" tool, you can use it on the 10.6 or 10.7 AppKit framework. You'll see that most of the Cocoa protocols are present, but NSApplicationDelegate isn't.
On Jul 6, 2012, at 5:09 AM, ecir hana wrote:
> On Fri, Jul 6, 2012 at 11:56 AM, Ken Thomases <email@hidden> wrote:
>
>>> 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).
>>
>
> Thank you. And please, can you explain to me why is it that case? Is it simply because AppKit includes the definition of NSTextViewDelegate protocol and not includes one for NSApplicationDelegate?
Correct.
> Is it somewhere documented which protocols are not included?
I doubt it. It's not that anybody made a conscious decision to omit NSApplicationDelegate. It's just a consequence of how the code was written and what the compiler and linker do.
> I mean, besides NSApplicationDelegate, what other delegate definitions cannot be obtained at runtime?
Who knows. It depends entirely on what the AppKit code used and what the compiler and linker did with that.
> Or is there anything like AppKit which, after being loaded, provides the definitions?
Anything which referenced them in the described manner (includes a class which adopted them or code which references them via @protocol()).
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