• 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
Receiving app launch notification in command line tool
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: background of NSButton and NSPopUpButton
  • Next by Date: getting a list of connected displays
  • Previous by thread: Re: background of NSButton and NSPopUpButton
  • Next by thread: getting a list of connected displays
  • Index(es):
    • Date
    • Thread