Re: NSUserDefaults
Re: NSUserDefaults
- Subject: Re: NSUserDefaults
- From: Alexander von Below <email@hidden>
- Date: Sat, 02 Oct 2010 23:40:40 +0200
You don't do that with Xcode. Please read the documentation for NSUserDefaults:
http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/UserDefaults/Tasks/UsingDefaults.html#//apple_ref/doc/uid/20000719-97292
Alex
Am 02.10.2010 um 23:35 schrieb David Blanton:
> Well I am not sure if I am asking the right question or just be dense.
>
> When my app runs for the first time I want default values to use. Trying to avoid code like this
>
> NSUserDefaults *dflts = [NSUserDefaults standardUserDefaults];
> float hfeet = [dflts floatForKey:@"cFeetH"];
> if(hfeet == 0.0)
> { // set default
> [dflts setFloat:100.0 forKey:@"cFeetH"];
> [dflts setFloat:60.0 forKey:@"cFeetV"];
> hfeet = 100.0;
> }
> float vfeet = [dflts floatForKey:@"cFeetV"];
>
> i.e these key values would already be in my user defaults. Now that I think about it the question makes no sense.
>
> I guess there should be an install script that runs and sets NSUserDefaults ... how would that work?
>
>
>
>
> On Oct 2, 2010, at 3:14 PM, Greg Guerin wrote:
>
>> David Blanton wrote:
>>
>>> Can key/values for user NSUserDefaults be set in xcode?
>>
>>
>> Describe exactly what you mean.
>>
>> If you mean "Can I write a Shell Script Build Phase that runs the 'defaults' command to set some keys to certain values, for a particular bundle identifier, for the current user?", then the answer is "Yes". You could also use the 'PlistBuddy' command to accomplish similar things: /usr/libexec/PlistBuddy. Both commands have man pages.
>>
>> If you mean something else, you'll have to explain exactly what you want to happen.
>>
>> -- GG
>> _______________________________________________
>> 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
>>
>>
>
> _______________________________________________
> 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
_______________________________________________
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