[SOLVED] How to identify the host app is Carbon or Cocoa in a context menu plugin.
[SOLVED] How to identify the host app is Carbon or Cocoa in a context menu plugin.
- Subject: [SOLVED] How to identify the host app is Carbon or Cocoa in a context menu plugin.
- From: Satoshi Matsumoto <email@hidden>
- Date: Fri, 07 Jul 2006 11:09:23 +0900
- Thread-topic: [SOLVED] How to identify the host app is Carbon or Cocoa in a context menu plugin.
on 06.7.7 10:35 AM, Satoshi Matsumoto at email@hidden wrote:
> On PowerPC Mac, NSApp is always nil in Carbon apps. So I can easily identify
> Carbon or Cocoa by checking NSApp value.
>
> But on Intel Mac, NSApp has non zero value even in Carbon apps.
>
> Does anybody know how to identify the host app is Carbon or Cocoa on Intel
> Mac?
I have noticed the only Cocoa apps have "NSPrincipalClass" and
"NSMainNibFile" in its info-plist file.
This is my answer how to identifies the host app is Cocoa or not.
BOOL isHostACocoaApp()
{
NSAutoreleasePool *localPool;
BOOL ret = NO;
localPool = [[NSAutoreleasePool alloc] init];
if( NSApp == nil ) ret = NO;
else
{
NSBundle *bundle = [NSBundle mainBundle];
if( bundle )
{
NSDictionary *plist = [bundle infoDictionary];
NSString* primaryClass = [plist
objectForKey:@"NSPrincipalClass"];
NSString* mainNibFile = [plist objectForKey:@"NSMainNibFile"];
if (primaryClass && [primaryClass length] > 0 && mainNibFile &&
[mainNibFile length] > 0) ret =YES;
}
}
[localPool release];
return ret;
}
Thanks.
Satoshi
-----------------------------------------------------
Satoshi Matsumoto <email@hidden>
816-5 Odake, Odawara, Kanagawa, Japan 256-0802
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden