Challenge: Colored Text

Could anyone help me. I am at a total loss how to do this.
I make logLine into a MutableAttributedString, check to self if the message sender is self, booted not know how to set the attribute of a string to blue.

What I have written is:

[color=#0040FF]let caller = note.object as! ChatWindowController
if caller == self {
logLine.addAttribute(NSForegroundColorAttributeName, value: UIColor.blueColor(), range: NSMakeRange(0, logLine.length[/code]))
}
[/color]

but UIColor is regarded as an unresolved identifier.
Any help would be greatly appreciated

Try using NSColor in place of UIColor.

Thnaks. That did it. :smiley:

You can also use the triple equals operator to check the identity of self

1 Like