 |
 |
Launch another application from Cocoa?
|
 |
|
 |
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
What's the recommended way to Launch an existing Mac OS X application from within a Cocoa application? I don't want to send it any arguments, just launch it and make it the frontmost application.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status:
Offline
|
|
Here you go:
[[NSWorkspace sharedWorkspace] launchApplication:@"App"];
It'll automatically be frontmost.
|
|
you are not your signature
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
Originally posted by Gametes:
Here you go:
[[NSWorkspace sharedWorkspace] launchApplication:@"App"];
It'll automatically be frontmost.
Wow, that was simple. I've not looked into workspaces at all. I'd better look up the doco, just so I understand exactly what this is doing.
Thanks!
|
|
|
| |
|
|
|
 |
|
 |
|
Posting Junkie
Join Date: Dec 2000
Status:
Offline
|
|
If you want to launch an app from an object that only includes the Foundation, without having to use the AppKit, you can also do this:
Code:
NSBundle *bundle = [NSBundle bundleWithPath:@"/Applications/Mail.app"]; // or whatever app
NSString *path = [bundle executablePath];
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:path];
[task launch];
[task release];
task = nil;
More lines of code than Gametes' suggestion, to be sure, but it's handy if you don't want to include the AppKit for some object.
[edit: damn vB code, turning things that aren't supposed to be smileys into smileys...]
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status:
Offline
|
|
I've been wondering about the import dynamic in Cocoa. I mean, in an old-school C++ app, one would have to "#include" a needed file, which would actually insert the contents of the files into the final build, in order to ensure the code was there on whatever machine was running the app.
But in Cocoa, there is an absolute certainty that Apple's Appkit and Foundation frameworks will be on every machine. One has to physicially include private frameworks in the app, but linking to Cocoa shouldn't do anything to the size of the file, right? After all, why would doing so change it, since cocoa isn't actually included in the app?
I concede that if you don't use appkit, you shouldn't import it, but I don't understand why. It seems like it should be irrelevant.
|
|
you are not your signature
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|