Re: NSColor <-> NSString
Re: NSColor <-> NSString
- Subject: Re: NSColor <-> NSString
- From: Alex Rice <email@hidden>
- Date: Tue, 25 Dec 2001 00:50:04 -0700
On Monday, December 24, 2001, at 10:10 , Simson Garfinkel wrote:
Are there any standard methods or functions for converting between
NSColor
and NSString?
It looks like the colorWithCatalogName: might be the appropriate
function,
but I'mm not sure. The documentation doesn't make it clear if a catalog
name
is reserved for the named lists of colors.
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.
See ColorFormatter.m in:
http://www.bignerdranch.com/Solutions/21_Formatters/TypingTutor_21_A.tar.gz
Alex Rice <email@hidden>
Mindlube Software
http://www.mindlube.com/