Re: ScreenSaverDefaults woes...
Re: ScreenSaverDefaults woes...
- Subject: Re: ScreenSaverDefaults woes...
- From: Phillip Hutchings <email@hidden>
- Date: Wed, 14 Jan 2004 22:34:48 +1300
Yes, that works wonderfully, don't know why I hadn't thought of it.
I guess I assumed that NSColor would automatically write out a nice
format when requested to. Next time put brain in before programming ;)
On 14/01/2004, at 9:40 PM, Louis C. Sacha wrote:
Hello...
Actually, I don't think it is an issue of the colors being released.
You can't store NSColor objects in the defaults dictionary because
they are not a property list object, so what is probably happening is
that when you syncronize the defaults (which writes out the defaults
to a .plist file) the NSColor object can't be written out and is
causing the crash.
You need to archive the NSColors when you put them in the defaults and
unarchive them when you read from the defaults.
/* Typed in email, so user beware... */
/*
defaults is your instance of Screensaver defaults
textColorWell is your NSColorWell
textColorKey is your key for the defaults
*/
/* when you write to the defaults dictionary, you would do something
like this: */
[defaults setObject: [NSArchiver
archivedDataWithRootObject:[textColorWell color]] forKey:
textColorKey];
/* when you read the defaults , you would do something like this: */
[textColorWell setColor:[NSUnarchiver unarchiveObjectWithData:
[defaults objectForKey: textColorKey]]];
Hope that helps,
Louis
--
Phillip Hutchings
email@hidden
http://www.sitharus.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.