Receiving app launch notification in command line tool
Receiving app launch notification in command line tool
- Subject: Receiving app launch notification in command line tool
- From: Ralph Pöllath <email@hidden>
- Date: Thu, 25 Nov 2004 11:45:30 +0100
Hi,
is it possible to have a Cocoa command line tool launch an application
and be notified once the app is up and running?
It seems straightforward, but my tool never receives the notification.
Thanks,
-Ralph.
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
// launcher.m
// cc -framework Cocoa launcher.m -o launcher
// based on http://www.cocoabuilder.com/archive/message/2002/6/8/58057
// problem: launchNotification: never gets called
@interface NotifTarget:NSObject
@end
@implementation NotifTarget
+ (void) launchNotification: (NSNotification *) aNotification
{
NSLog(@"-%@ -- %@", NSStringFromSelector(_cmd), aNotification);
}
@end
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[[[NSWorkspace sharedWorkspace] notificationCenter]
addObserver: [NotifTarget class]
selector: @selector(launchNotification:)
name: NSWorkspaceDidLaunchApplicationNotification
object: nil];
if(![[NSWorkspace sharedWorkspace] launchApplication:@"TextEdit"]){
NSLog(@"app could not be launched");
}
else{
NSLog(@"app was launched, now waiting for
NSWorkspaceDidLaunchApplicationNotification");
[[NSRunLoop currentRunLoop] run];
}
[pool release];
return 0;
}
_______________________________________________
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