• 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
How do I get the NSApplication of other running applications?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do I get the NSApplication of other running applications?


  • Subject: How do I get the NSApplication of other running applications?
  • From: "Alan Smith" <email@hidden>
  • Date: Thu, 7 Sep 2006 17:15:16 -0400

Hi all,

I'm trying to do things with other apps and I think that the most
useful thing I can get to manipulate another app would be its
NSApplication instance. So, I tried this:

- (void)awakeFromNib
{
   [[[NSWorkspace sharedWorkspace] notificationCenter]
addObserver:self selector:@selector(notified:) name:nil object:nil];
}

- (void)dealloc
{
   [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self];
}

- (void)notified:(NSNotification *)theNotification
{
   NSLog(@"Notified of %@", [theNotification name]);
   NSDictionary *userDict = [theNotification userInfo];
   NSEnumerator *dictEnum = [userDict keyEnumerator];
   id nextKey;
   while (nextKey = [dictEnum nextObject])
       NSLog(@"%@ : %@", nextKey, [userDict valueForKey: nextKey]);
}

As a quick test to see what I got. It logged things like this:

Notified of NSWorkspaceDidTerminateApplicationNotification
NSApplicationProcessIdentifier : 304
NSApplicationBundleIdentifier : com.apple.TextEdit
NSApplicationProcessSerialNumberHigh : 0
NSApplicationProcessSerialNumberLow : 2097153
NSApplicationPath : /Applications/TextEdit.app
NSApplicationName : TextEdit

So with that info I should be able to get TextEdit's NSApplication
instance. The only question is: how do I do it?

Many thanks, Alan

--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"Don't waste your life doing things others have already done."
_______________________________________________
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: How do I get the NSApplication of other running applications?
      • From: Pascal Pochet <email@hidden>
    • Re: How do I get the NSApplication of other running applications?
      • From: "Shawn Erickson" <email@hidden>
  • Prev by Date: CIPageCurlTransition Problems
  • Next by Date: WebKit
  • Previous by thread: CIPageCurlTransition Problems
  • Next by thread: Re: How do I get the NSApplication of other running applications?
  • Index(es):
    • Date
    • Thread