In case anyone else is having a hard time with this, I think I got it working. Oddly cellcortex's answer works using setTextColor, but any changes made using setAttributedStringValue on the built-in textField are still overwritten. If you subclass NSTableCellView and make custom outlet to the NSTextField, you can modify the attributed string value though this outlet and not have your changes overwritten.
Here's how I did it with a view-based NSOutlineView: The outline view has a column with the identifier "Detail". This column has a subclassed NSTableCellView (DBTableCellView) with the identifier "DetailCellView". This DBTableCellView has an NSTextField inside of it. DBTableCellView has an outlet to the NSTextField it encompasses called "customTextField".
The outline view delegate has this method:
- (NSView*)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item{
NSString *identifier = [tableColumn identifier];
if ([identifier isEqualToString:@"Detail"]) {
DBTableCellView * cellView = [outlineView makeViewWithIdentifier:@"DetailCellView" owner:self];
NSTextField * textField = cellView.customTextField;
NSString * originalString = [textField stringValue];
if (originalString.length > 0){
[textField setAllowsEditingTextAttributes: YES];
[textField setSelectable: YES];
NSMutableAttributedString* attrString = [[NSMutableAttributedString alloc] initWithString:originalString];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSColor blueColor], NSForegroundColorAttributeName,
[NSNumber numberWithInt:NSSingleUnderlineStyle],NSUnderlineStyleAttributeName, nil];
NSRange range = NSMakeRange(0, [attrString length]);
[attrString addAttributes:attributes range:range];
[textField setAttributedStringValue: attrString];
}
return cellView;
} else { //specify other column identifiers here later
return NULL;
}
}