Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Adding color to NSMutableAttributedString

Adding color to NSMutableAttributedString
Thread Tools
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Apr 6, 2002, 09:55 AM
 
I am having trouble adding color to a string. Here is my code:

-(NSMutableAttributedString *)sarticleTitle {
NSMutableAttributedString *returnTitle;
if ([self newReference]==YES) {
returnTitle=[[NSMutableAttributedString alloc] initWithString:[self articleTitle]];
[returnTitle addAttribute:NSForegroundColorAttributeName value:[NSColor redColor] range:NSMakeRange(0,3)];
}
else {
// returnTitle=[self articleTitle];
}
return returnTitle;
}

articleTitle is different from sarticleTitle and is just an NSString (it was the simple accessor method before I decided to add color). Here are the errors I am getting:

reference.m:70: `NSForegroundColorAttributeName' undeclared (first use in this function)

reference.m:70: `NSColor' undeclared (first use in this function)

Oh yeah, If I leave out the range: argument will it apply the attribute to the whole string?

thanks,
kman
     
kman42  (op)
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Apr 6, 2002, 09:57 AM
 
Nevermind. I'm a dumbass and forgot to import Cocoa into that class. Doh!

kman
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:52 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2