Re: NSUserDefaults, an array, and SIGBUS 10
Re: NSUserDefaults, an array, and SIGBUS 10
- Subject: Re: NSUserDefaults, an array, and SIGBUS 10
- From: Ondra Cada <email@hidden>
- Date: Mon, 29 Jul 2002 17:49:24 +0200
On Monday, July 29, 2002, at 04:42 , Scott Anguish wrote:
this category on NSUserDefaults adds support for archiving NSColor..
you can see from this how to archive your own data
- (void)setColor:(NSColor *)color forKey:(NSString *)key {
NSData *data=[NSArchiver archivedDataWithRootObject:color];
[self setObject:data forKey:key];
}
Although this works perfectly for any object(*), for colours and similar
values it is much better -- if possible -- to use some string- or
number-based encoding (like RGB values). The difference lays in the
possibility to change the default value easily externally, eg. using the
CLI defaults tool.
RGB is great with the exception that the color you may be storing is
actually CMYK, or Grayscale...
Sure. That was the "if possible" part.
What's more, you'd store it one way, someone else another, etc...
'Course, in my personal opinion, NSColor placement is one of (relatively
small number of) OpenStep design bugs: it should have been part of
Foundation (just like, incidentally, NSImage), and it should have been
propertylistable, if there is such a word ;)))
Pity that Apple, when changing the OpenStep anyway, did not fix those bugs
(other well-known one is the ambiguous -compare: signature; offhand, I can'
t recall another). Triple alas they did not -- due to that, we have to DIY
whenever needed, and the way which is best for the actual usage. Which
might be RGB or archived NSData (or even both), depending on the actual
application...
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
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.