Re: how do I check the defaults for an object?
Re: how do I check the defaults for an object?
- Subject: Re: how do I check the defaults for an object?
- From: Sherm Pendley <email@hidden>
- Date: Sat, 27 May 2006 13:39:42 -0400
On May 27, 2006, at 1:17 PM, Alan Smith wrote:
I need to get an array from UserDefaults but the first time this app
is run there won't be that array. That's not the only time either. So,
I need to check to see if that array exists so the app doesn't crash,
You need to provide a sensible "default defaults" dictionary that
will be used if the user hasn't provided their own. You want to do
that early in your app's lifetime - like in -
applicationWillFinishLaunching:. Here's an example - it's in Perl,
but the idea is still clear; you'd call the same methods in Objective-C.
my $defaults = NSUserDefaults->standardUserDefaults();
my $appDefaults = {
'docSets' => [
{ 'name' => '* Default *',
'podPath' => $Config{'privlib'}.'/pods',
'corePath' => $Config{'privlib'},
'cpanPath' => $Config{'sitelib'},
'vendorPath' => $Config{'vendorlib'},
'arch' => $Config{'archname'}
},
],
'ClearCacheOnExit' => 0,
'ShowTip' => 1,
'ShowIntro' => 1,
'CacheDir' => NSHomeDirectory() . '/Library/Caches/ShuX',
'StylesheetType' => 0,
};
$defaults->registerDefaults($appDefaults);
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden