• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ScreenSaverDefaults woes...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >ScreenSaverDefaults woes... (From: Phillip Hutchings <email@hidden>)
 >Re: ScreenSaverDefaults woes... (From: "Louis C. Sacha" <email@hidden>)

  • Prev by Date: Re: How to completely release every object allocated when opening a NIB file ?
  • Next by Date: Re: How to completely release every object allocated when opening a NIB file ?
  • Previous by thread: Re: ScreenSaverDefaults woes...
  • Next by thread: nspopupbuttoncell as textattachment
  • Index(es):
    • Date
    • Thread