Re: NSApplication and command line args
Re: NSApplication and command line args
- Subject: Re: NSApplication and command line args
- From: Andrew Farmer <email@hidden>
- Date: Fri, 8 May 2009 15:03:20 -0700
On 07 May 09, at 12:36, Brian Arnold wrote:
I have recently converted an application which processes command line
arguments to call NSApplicationMain when it starts up, and defer
command line processing until later in a separate thread. The
deferred command line processing still works; however, I am seeing a
new behavior where, in some circumstances, NSApplication is passing
certain arguments to openFiles, which is undesirable. For example,
there may be a command line argument '-logfile /foo/bar', where '/foo/
bar' is also being passed to openFiles.
My proposed solution is to detect when an argument is being passed to
openFiles during startup (i.e., when the arguments are being
processed), and filter it out. I do this by using a boolean flag
which is initialized to false and set to true when
applicationDidFinishLaunching is called on my delegate. If openFiles
is called when sIsRunning is false, I perform this extra check if it's
on the command line and ignore it if it is.
<snip...>
A much simpler solution would be to preprocess the arguments which you
pass to NSApplicationMain. Run through everything in argv, then create
a new array of arguments from that with all arguments your application
wants to handle removed and pass that to AppKit.
_______________________________________________
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