If you want to keep him human, read. I made a category for this:
@implementation UIColor (EPPZRepresenter) NSString *NSStringFromUIColor(UIColor *color) { const CGFloat *components = CGColorGetComponents(color.CGColor); return [NSString stringWithFormat:@"[%f, %f, %f, %f]", components[0], components[1], components[2], components[3]]; } UIColor *UIColorFromNSString(NSString *string) { NSString *componentsString = [[string stringByReplacingOccurrencesOfString:@"[" withString:@""] stringByReplacingOccurrencesOfString:@"]" withString:@""]; NSArray *components = [componentsString componentsSeparatedByString:@", "]; return [UIColor colorWithRed:[(NSString*)components[0] floatValue] green:[(NSString*)components[1] floatValue] blue:[(NSString*)components[2] floatValue] alpha:[(NSString*)components[3] floatValue]]; } @end
The same formatting used by NSStringFromCGAffineTransform. This is actually part of the representative of the larger plist object in [eppz! Kit on GitHub] [1].
Geri
source share