• 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: Hirendra Rathor <email@hidden>
  • Date: Mon, 11 Jul 2011 23:05:29 +0530
  • Acceptlanguage: en-US
  • Thread-topic: Can we get command line arguments in applicationShouldHandleReopen?

OK, I will use apple events for this.

Thanks
Hirendra

From: Jens Alfke [mailto:email@hidden]
Sent: Friday, July 08, 2011 9:28 PM
To: Hirendra Rathor
Cc: email@hidden
Subject: Re: Can we get command line arguments in applicationShouldHandleReopen?


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

References: 
 >Can we get command line arguments in applicationShouldHandleReopen? (From: Hirendra Rathor <email@hidden>)
 >Re: Can we get command line arguments in applicationShouldHandleReopen? (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: How to disable double tap on UIWebView
  • Next by Date: Custom crop rect box in UIImagePickerViewController
  • Previous by thread: Re: Can we get command line arguments in applicationShouldHandleReopen?
  • Next by thread: User Defaults Controller Binding
  • Index(es):
    • Date
    • Thread