#import "CellAdditions.h" @implementation NSCell (CellAdditions) - setAttributedStringBackground:(NSColor *)bg { NSAttributedString *attrstr = [self attributedStringValue], *tempstr; NSMutableDictionary *attrdict = [NSMutableDictionary dictionaryWithDictionary: [attrstr attributesAtIndex:0 effectiveRange:NULL]]; if(bg!=nil){ [attrdict setObject:bg forKey:NSBackgroundColorAttributeName]; } else if([attrdict objectForKey: NSBackgroundColorAttributeName]!=nil){ [attrdict removeObjectForKey: NSBackgroundColorAttributeName]; } tempstr = [[NSAttributedString alloc] initWithString:[attrstr string] attributes:attrdict]; AUTORELEASE(tempstr); [self setAttributedStringValue:tempstr]; return self; } @end