• 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: "Louis C. Sacha" <email@hidden>
  • Date: Wed, 14 Jan 2004 00:40:23 -0800

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


I'm trying to give my screensaver preferences. It works fine with everything except NSColor, for text and background colours.

I'm getting the colours from an NSColorWell in to an NSColor*, like this:

NSColor *newTextColour = [textColour color];
NSColor *newBgColour = [backgroundColour color];

But when I try to synchronise the defaults, it crashes.

The problem is the NSColors are being released somewhere, I've logged the retain counts from an NSLog() and I get this:
Retain Counts: newTextColour:4294967295 newBgColour:4294967295
Just after getting them.

Checking from the debugger, the type of the two NSColors is NSCachedWhiteColor. Now, I know that at least one of those is set to black, and I have no idea why I'm getting those and not an NSColor, as the documentation suggests. I know they're both linked properly in IB.

Any ideas?

This is on 10.3, but the screensaver is supposed to work on 10.2 as well.
--
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.

  • Follow-Ups:
    • Re: ScreenSaverDefaults woes...
      • From: Phillip Hutchings <email@hidden>
References: 
 >ScreenSaverDefaults woes... (From: Phillip Hutchings <email@hidden>)

  • Prev by Date: Re: [help!] a strange crash (to me)...
  • Next by Date: Re: iChat "Sort by..." animation
  • Previous by thread: ScreenSaverDefaults woes...
  • Next by thread: Re: ScreenSaverDefaults woes...
  • Index(es):
    • Date
    • Thread