• 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: Passing non-string user defaults through command line arguments
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing non-string user defaults through command line arguments


  • Subject: Re: Passing non-string user defaults through command line arguments
  • From: Chris Suter <email@hidden>
  • Date: Wed, 06 Apr 2011 09:43:48 +1000

Hi Justin,

On Wed, Apr 6, 2011 at 9:35 AM, Justin C. Walker <email@hidden> wrote:

> Unless I misunderstand this, the program still has to know, or be told, that the (string!) arguments have to be translated/interpreted as the specified "objects".

Yes, you're right and that's exactly what happens. The implementation
of NSUserDefaults in Foundation (or at least I'm assuming that's where
the code is), parses the command line arguments and registers those
defaults in the argument domain.

Try this program:

#import <Foundation/Foundation.h>

int main (void)
{
  [[NSAutoreleasePool alloc] init];
  NSUserDefaults *d = [NSUserDefaults standardUserDefaults];

  id obj = [d objectForKey:@"test"];

  NSLog (@"%@ %@", [obj className], obj);

  return 0;
}

Run it like this:

./test -test '<integer>1</integer>'

If you’re wondering how Foundation gets hold of argc and argv, it does
it via global variables that come from the runtime.

Kind regards,

Chris
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Passing non-string user defaults through command line arguments
      • From: "Justin C. Walker" <email@hidden>
References: 
 >Passing non-string user defaults through command line arguments (From: Christiaan Hofman <email@hidden>)
 >Fwd: Passing non-string user defaults through command line arguments (From: Chris Suter <email@hidden>)
 >Re: Passing non-string user defaults through command line arguments (From: "Justin C. Walker" <email@hidden>)

  • Prev by Date: Re: Passing non-string user defaults through command line arguments
  • Next by Date: Re: Passing non-string user defaults through command line arguments
  • Previous by thread: Re: Passing non-string user defaults through command line arguments
  • Next by thread: Re: Passing non-string user defaults through command line arguments
  • Index(es):
    • Date
    • Thread