• 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
Re: Can we get command line arguments in applicationShouldHandleReopen?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can we get command line arguments in applicationShouldHandleReopen?


  • Subject: Re: Can we get command line arguments in applicationShouldHandleReopen?
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 08 Jul 2011 08:58:10 -0700

On Jul 8, 2011, at 7:13 AM, Hirendra Rathor wrote:

> I have written an .app which is launched many times until the running instance shuts down finally. The code
> to start it looks like this:
>
>    NSTask* task = [[NSTask alloc] init];
>    [task setLaunchPath: @"/usr/bin/open"];

That’s pretty awkward! The preferred way to launch an app is to use the NSWorkspace methods, or LaunchServices (a lower-level procedural API that gives you more options.)

> The idea is to launch the application with different arguments so that it can do different
> stuff every time. This design is inspired as a result of porting this code from other platforms, so I
> would be willing to look at other design alternatives if it does not work well in the Mac world. However
> I would like to give existing solution a try before I do that.

Don’t use command-line args for this. To send parameters when launching an application, use AppleEvents. LaunchServices supports sending an arbitrary/custom AppleEvent to an app while launching it.

—Jens_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • RE: Can we get command line arguments in applicationShouldHandleReopen?
      • From: Hirendra Rathor <email@hidden>
References: 
 >Can we get command line arguments in applicationShouldHandleReopen? (From: Hirendra Rathor <email@hidden>)

  • Prev by Date: User Defaults Controller Binding
  • Next by Date: Re: NSMapTable on iOS?
  • Previous by thread: Re: Can we get command line arguments in applicationShouldHandleReopen?
  • Next by thread: RE: Can we get command line arguments in applicationShouldHandleReopen?
  • Index(es):
    • Date
    • Thread