Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 936575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:20:12+00:00 2026-05-15T21:20:12+00:00

I found there are at least three ways to launch an app with Mac

  • 0

I found there are at least three ways to launch an app with Mac OS X from an application.

  1. NSTask. I can give parameters, but it seems that it’s not for an Cocoa App, but an UNIX style binary.
  2. system function (system()) just the same way as C does. I don’t know the reason why but it seems that nobody recommends this method.
  3. NSWorkspace, but I can’t find a way to pass parameters to this function.

Questions

  • Q1 : Is there any other way to launch an App (from an App) other than three methods?
  • Q2 : What’s the pros and cons for each method?
  • Q3 : What’s the preferable way for launching an App (from an App)?
  • Q4 : What’s the preferable way for launching an App with parameters (from an App)?
  • Q5 : What’s the preferable way to open a document (from an App)?

ADDED

  • NSWorkspace openFile:withApplication: : For running “TextMate README.txt”, based on Roadmaster’s answer and this code, I could make it as follows.
    But, I can’t give the parameters to the App.
    NSString * path = @"/Users/smcho/Desktop/README.txt";
    NSURL * fileURL = [NSURL fileURLWithPath: path];
    NSWorkspace * ws = [NSWorkspace sharedWorkspace];
    [ws openFile:[fileURL path] withApplication:@"TextMate"];
  • NSWorkspace launchApplicationAtURL:options: : It works with 10.6 or later, you can get an example from this question.
    NSURL * bURL = [[NSWorkspace sharedWorkspace] URLForApplicationWithBundleIdentifier:@"com.macromates.textmate"];
    NSWorkspace * ws = [NSWorkspace sharedWorkspace];
    [ws launchApplicationAtURL:bURL options:NSWorkspaceLaunchDefault configuration:nil error:nil];
  • NSTask : This is the working code. I need to give the correct binary path, and it doesn’t look like a Cocoa way, as it’s for running binary, not bundle. Though, it’s possible to give more parameters than just a file name.
    [NSTask launchedTaskWithLaunchPath:@"/Applications/TextMate.app/Contents/MacOS/TextMate"     arguments:[NSArray arrayWithObjects:@"hello.txt", nil]];
  • system() : With the shell, I could run “system(open -a ABC –args hello.txt)”, just like I do with the command line. It seems that this is the easiest way to go.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T21:20:12+00:00Added an answer on May 15, 2026 at 9:20 pm

    In 10.6 and later, NSWorkspace has a method launchApplicationAtURL:options:configuration:error: that can be used to pass arguments to the app.

    There are also Launch Services functions such as LSOpenItemsWithRole.

    You could also send an AppleEvent to the Finder asking it to open something.

    EDIT TO ADD: “best” is subjective, but I’d say if you can use NSWorkspace, use it. If you can’t, e.g., you need to pass command-line parameters and you need to support Leopard, then use Launch Services.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found there are two ways to approach it, ReadDirectoryChangesW and FindFirstChangeNotification . I
I found this PECL package called threads , but there is not a release
I found this link http://artis.imag.fr/~Xavier.Decoret/resources/glsl-mode/ , but there isn't a lot of description around
I have found that there is generally a singe type or namespace that takes
By looking at our DB's error log, we found that there was a constant
I have just installed Eclipse 3.4 and found out that there is not a
I recently asked a question about IIf vs. If and found out that there
There's one thing I haven't found in RFC 2616 ("Hypertext Transfer Protocol -- HTTP/1.1")
Is there a ColdFusion analog for the deployment descriptor/web.xml file found in a J2EE
is there a way to change an oracle user's default schema? I found it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.