• 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: NSApplicationMain arguments
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSApplicationMain arguments


  • Subject: Re: NSApplicationMain arguments
  • From: Ken Thomases <email@hidden>
  • Date: Sat, 12 Apr 2008 05:45:34 -0500

On Apr 12, 2008, at 5:08 AM, email@hidden wrote:
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.

That seems like a peculiar goal. If you don't want to know what was really passed on the command line, why perform a query that returns what is passed on the command line? As suggested, just put the data you're interested in somewhere else and look it up from there.


In your original email, the argument list you set up wasn't constructed in a way which would have affected NSArgumentDomain. Perhaps that was just for illustration purposes, but you would need something like { arg1, "-someDefaultKey", "theValue", NULL }. Note the leading dash on the key.

You can also try replacing the contents of the NSArgumentDomain in the shared user defaults object by doing:

NSDictionary* myValues = [NSDictionary dictionaryWith...];
[[NSUserDefaults sharedUserDefaults] removeVolatileDomainForName:NSArgumentDomain];
[[NSUserDefaults sharedUserDefaults] setVolatileDomain:myValues forName:NSArgumentDomain];


This will only affect the shared user defaults object. Code which allocates and initializes its own NSUserDefaults object presumably won't see the same contents. Also, an invocation of +[NSUserDefaults resetStandardUserDefaults] will undo that replacement.

-Ken
_______________________________________________

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: NSApplicationMain arguments
      • From: Ken Thomases <email@hidden>
References: 
 >NSApplicationMain arguments (From: email@hidden)
 >Re: NSApplicationMain arguments (From: Michael Vannorsdel <email@hidden>)
 >Re: NSApplicationMain arguments (From: email@hidden)

  • Prev by Date: Re: Override AppleScrollBarVariant on NSScroller?
  • Next by Date: Re: NSApplicationMain arguments
  • Previous by thread: Re: NSApplicationMain arguments
  • Next by thread: Re: NSApplicationMain arguments
  • Index(es):
    • Date
    • Thread