Re: NSColor <-> NSString
Re: NSColor <-> NSString
- Subject: Re: NSColor <-> NSString
- From: "Simson Garfinkel" <email@hidden>
- Date: Tue, 25 Dec 2001 09:28:00 -0500
thanks for the pointer. A bit more complicated than what I want, to be sure.
I was hoping that there would be some simple thing in the AppKit for
transforming a Color into a String, the way there is stuff for coding other
basic values into strings. I don't want a list of colors; I just want one
color. I guess I'll need to write it.
I think that one of the fundamental differences between _Cocoa Programming
for Mac OS X_ and the book that I am doing with Michael Mahoney is that our
code examples all try to be as compact as possible, to show off the essence
of the AppKit. There are a few exceptions to this, but in general, we've
tried to design all of the applications in this manner.
>
>
NSColorList has
>
-(NSColor *) colorWithKey:(NSString *) key
>
>
On page 296 of the new _Cocoa Programming for Mac OS X_ book, there is
>
an example class ColorFormatter which as an NSFormatter converts from
>
Strings to NSColors and vice-versa.
>
It has some code for converting from an arbitrary color to the nearest
>
named color string in an NSColorList, and searching through color lists
>
for substrings.