Re: NSApplicationMain arguments
Re: NSApplicationMain arguments
- Subject: Re: NSApplicationMain arguments
- From: email@hidden
- Date: Sat, 12 Apr 2008 12:08:35 +0200
> If you're using NSProccessInfo to get the args, then changing them at runtime won't work
> as far as I know. The args are stored before main is even called. I don't think passing
> args to NSApplicationMain has any kind of effect.
No, I'm not getting the args from NSProcessInfo but from argsv[], like
in the code I posted:
int main(int argc, char *argv[])
{
int new_argc = 2;
char* arg1 = argv[0];
char *new_argv[] = { arg1, "foo", "bar", NULL };
return NSApplicationMain(new_argc, (const char **) new_argv);
}
If I set some args for testing purposes in XCode I can see these args
being passed to NSApplicationMain, but oddly enough replacing them at
launch have no effect. What I want is to include the arguments in the
shipping product.
> Couldn't you just store your custom args in a global and access them later when you need
> them?
My goal is to replace an existing setting in the NSArgumentDomain, so
storing the setting in the application domain isn't good enough as
NSArgumentDomain takes precedence over the application defaults. The
docs only talk about setting NSArgumentDomain args from the
command-line, but since they are passed to NSApplicationMain I figured
I could also set them programmatically somehow.
The only work-around I can think of is to put the entire app in a
wrapper that simply launches the bundled app with the desired command
line arguments, but I don't consider this a very elegant solution.
> On Apr 11, 2008, at 8:01 PM, email@hidden wrote:
>
>
> > 'm trying to add some launch arguments to my executable by modifying
> > the arguments passed to main.m, but find that the new arguments are
> > completely ignored. No matter what I pass to NSApplicationMain the
> > executable launches with the same old default argsv[]. Is this not the
> > right approach? Should I rather subclass NSApplication? If so, how?
> > Any help appreciated. Thanks.
> >
>
>
> _______________________________________________
>
> 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
>
_______________________________________________
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