Re: Passing non-string user defaults through command line arguments
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