How do I get the NSApplication of other running applications?
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