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: "Justin C. Walker" <email@hidden>
- Date: Tue, 05 Apr 2011 16:54:37 -0700
Hi, Chris,
On Apr 5, 2011, at 16:43 , Chris Suter wrote:
> 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.
Ah! The light filters through...
> 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.
Now I get it. It's funny how we can all be using English, yet still not speak the same language :-}
I'm an old (emphasis on the first syllable) C/kernel hacker. In C, there's no magic, like there is in these new-fangled languages like C++ and Obj-C :-}
Mathematicians and physicists have known for a long time that notation is critical in communication, but we keep forgetting it in the programming world. A few lines of code speaks volumes. Thanks for clarifying, and sorry for the waste of bandwidth circling the problem...
Justin
--
Justin C. Walker, Curmudgeon at Large
Director
Institute for the Enhancement of the Director's income
-----------
Question 43:
What if the hokey pokey
really *is* what it’s all about?
--
_______________________________________________
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