ftp.nice.ch/Attic/openStep/tools/workspace/TheShelf.0.3.3.sd.tgz#/TheShelf.0.3.3.sd/Source/NSUserDefaults+MiscColorExtensions.m

This is NSUserDefaults+MiscColorExtensions.m in view mode; [Download] [Up]

/*************************************************************************
 * File Name: NSUserDefaults+MiscColorExtensions.m
 * Version  : 0.0 alpha
 * Date     : Tue 02-Sep-1997
 *************************************************************************
 *  COPYWHAT (C) 1997 by Tomi Engel
 *
 * This notice may not be removed from this source code.
 * The use and distribution of this software is governed by the
 * terms of the MiscKit license agreement.  Refer to the license
 * document included with the MiscKit distribution for the terms.
 *                    ALL RIGHTS RESERVED
 *
 *************************************************************************
 * Notes      :
 * Bugs       :
 * Author(s)  : tsengel
 * Last update: $Date: 1997/09/02 12:10:22 $
 * History    : $Log: NSUserDefaults+MiscColorExtensions.m,v $
 * History    : Revision 1.1  1997/09/02 12:10:22  tsengel
 * History    : Create category to add more convenience methods
 * History    :
 *************************************************************************/

#import "NSUserDefaults+MiscColorExtensions.h"

#import "NSColor+MiscExtensions.h"
#import "NSDictionary+MiscDefaultsSupport.h"

@implementation NSUserDefaults (MiscColorExtensions)

/*"
    These are extensions to the NSUserDefaults class which can handle additional non-NSPPL compliant object values. The propalby most wanted is easy NSColor support.
"*/

- (void)setColor:(NSColor *)aColor forKey:(NSString *)defaultName
/*"
    Uses #setObject:forKey: to set the string value return by aColor's #stringRepresentation method. 
"*/
{
    [self setObject:[aColor stringRepresentation] forKey:defaultName];
}

- (NSColor *)colorForKey:(NSString *)defaultName
/*"
   Invokes #stringForKey: with key defaultName and uses the retrieved string to recreate the color object. This method uses NSColors #colorWithStringRepresentation: method which has to ensure that decoding of NSColor sublasses is handled properly.
"*/
{
    return [NSColor colorWithStringRepresentation:[self stringForKey:defaultName]];
}

@end


@implementation NSDictionary (MiscColorExtensions)

- (NSColor *)colorForKey:(id)aKey
/*"
       Invokes #stringForKey: with the parameter aKey and uses the retrieved string to recreate the color object. This method uses NSColors #colorWithStringRepresentation: method which has to ensure that decoding of NSColor sublasses is handled properly.
"*/
{
    return [NSColor colorWithStringRepresentation:[self stringForKey:aKey]];
}

@end


@implementation NSMutableDictionary (MiscColorExtensions)

- (void)setColor:(NSColor *)aColor forKey:(id)aKey
/*"
     Uses #setObject:forKey: to set the string value return by aColor's #stringRepresentation method.
"*/
{
    [self setObject:[aColor stringRepresentation] forKey:aKey];
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.