Re: can't Serialize NSColor
Re: can't Serialize NSColor
- Subject: Re: can't Serialize NSColor
- From: Chris Parker <email@hidden>
- Date: Wed, 7 Nov 2001 14:09:54 -0800
Hi Jake,
NSUserDefaults only handles property list-able (NSDictionary, NSArray,
etc) objects in this manner. You have to explicitly serialize the
NSColor to data in order to do this.
NSColor can be archived (via NSArchiver) like so:
[defaults setObject:[NSArchiver archivedDataWithRootObject:myColor
forKey:@"myColor"]];
When you get the key, you'll have to deserialize it before you can use
it.
The fact that it crashes is a known bug and has been addressed.
.chris
On Wednesday, November 7, 2001, at 01:28 PM, Jake wrote:
according to the documentation
NSColor Conforms to: NSCoding,NSCopying, NSObject (NSObject)
However
NSColor *myColor = [NSColor whiteColor];
[defaults setObject:myColor forKey:@"myColor"];
crashes. Am I doing somethng wrong here or is NSColor incomplete?
--
Chris Parker <email@hidden>
Cocoa Frameworks Engineer
Catapultum habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum
saxum immane mittam.