O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

NSColorList — Mac OS X 10.0

Synopsis

This class manages an ordered, named list of NSColors. The operating system itself provides several color lists, which are visible in the Color panel of any application. To obtain an array of available color lists, use the class method availableColorLists. To manage the colors contained within a color list we have several methods at our disposal. The method colorWithKey: will return the color associated with the indicated key. Colors are added to the list using the method insertColor:key:atIndex:. To remove a color, use removeColorWithKey:. To change which color is associated with a key, use the method setColor:forKey:.

An important feature of color list objects is that they can be written to files that are kept in well-known locations in the filesystem, thus making them easily accessed by other applications. To store a color list to file, use the method writeToFile:. Passing nil to this method causes the color list to be stored in the users private color lists directory with the filename listname.clr. To initialize a color list object from a stored color list, use the initializer initWithName:fromFile:.

image with no caption

@interface NSColorList : NSObject <NSCoding>
                                  // Initializers
   - (id)initWithName:(NSString *)name 
                                 fromFile:(NSString *)path;
   - (id)initWithName:(NSString *)name;
                                  // Accessor Methods
   - (void)setColor:(NSColor *)color 
                                 forKey:(NSString ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required