Defaults not stored
Defaults not stored
- Subject: Defaults not stored
- From: Steve Mills <email@hidden>
- Date: Wed, 03 Apr 2013 22:56:52 -0500
My screensaver follows examples I've seen as far as creating its defaults in its initWithFrame method:
ScreenSaverDefaults* defaults = [ScreenSaverDefaults defaultsForModuleWithName:MyModuleName];
// Register our default values:
fileMan = [[NSFileManager alloc] init];
NSURL* defaultURL = [NSURL URLWithString:@"/Applications"];
NSArray* pictFolders = [fileMan URLsForDirectory:NSPicturesDirectory inDomains:NSUserDomainMask];
if(pictFolders != nil && [pictFolders count] > 0)
defaultURL = [[pictFolders objectAtIndex:0] filePathURL];
[defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
defaultURL, kImageFolderPathPrefKey,
[NSNumber numberWithInteger:NSOnState], kUsePolaroidBorderPrefKey,
nil]];
Then later in my startAnimation method I grab that value, but it's nil:
ScreenSaverDefaults* defaults = [ScreenSaverDefaults defaultsForModuleWithName:MyModuleName];
NSURL* url = [defaults URLForKey:kImageFolderPathPrefKey];
I tried calling [defaults synchronize] after registerDefaults, but that didn't help. I also tried creating a mutable dictionary and adding the url and integer via setObject:forKey:. No matter which method I use to create the defaults, I can definitely *see* the url in the defaults object, but it comes out nil when I ask for URLForKey. If I actually go through the System Preferences window and set my screen saver's prefs from there, then the url comes out as a valid value.
What am I doing wrong?
--
Steve Mills
Drummer, Mac geek
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden