Text Coloring

Look in the Attributed Strings Programming Guide.

NSAttributedString has the method
Code:
- (void)addAttribute:(NSString *)name value:(id)value range:(NSRange)aRange

which can be used like this to make letters 3-5 in the string red:
Code:
[string addAttribute:NSForegroundColorAttributeName value:[NSColor redColor] range:NSMakeRange(3, 2)];
 
This is the error I get:
2006-02-05 21:51:16.292 <ProjectName>[1549] *** -[NSBigMutableString addAttribute:value:range:]: selector not recognized

And this is my code:
NSMutableAttributedString *code=[editor_code string];
...

[code addAttribute:NSForegroundColorAttributeName value:[NSColor redColor] range:NSMakeRange(3, 2)];
[editor_code setString:code];


-------------------------

I also have another question, to get a NSTextView's contents as a string is this what you would do: '[anNSTextView string];'

And to set it's contents to a string: '[anNSTextView setString:aString];'?

Would this be any different if I were to use an NSMutableAttributedString?

Any help is more than welcome.
 
Back
Top