• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[SOLVED] How to identify the host app is Carbon or Cocoa in a context menu plugin.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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

  • Follow-Ups:
    • Re: [SOLVED] How to identify the host app is Carbon or Cocoa in a context menu plugin.
      • From: Rosyna <email@hidden>
References: 
 >How to identify the host app is Carbon or Cocoa in a context menu plugin. (From: Satoshi Matsumoto <email@hidden>)

  • Prev by Date: Newbie Q : writing into a text view programmatically
  • Next by Date: question about -init methods
  • Previous by thread: How to identify the host app is Carbon or Cocoa in a context menu plugin.
  • Next by thread: Re: [SOLVED] How to identify the host app is Carbon or Cocoa in a context menu plugin.
  • Index(es):
    • Date
    • Thread