Re: How to set the color of a string on a NSButton?
Re: How to set the color of a string on a NSButton?
- Subject: Re: How to set the color of a string on a NSButton?
- From: Nick Zitzmann <email@hidden>
- Date: Thu, 23 Nov 2006 00:16:04 -0700
On Nov 23, 2006, at 12:10 AM, David Hinz wrote:
The error I got at run time is:
-[NSCFString setAttributes:range:]: selector not recognized [self =
0x34df00]
This is what I tried:
NSDictionary *textDictionary = [NSDictionary dictionaryWithObject:
[NSColor whiteColor]
forKey:NSForegroundColorAttributeName];
[(NSMutableAttributedString *)([[threeButton stringValue]
mutableCopy]) setAttributes:textDictionary
range:NSMakeRange(0, [[threeButton
stringValue] length])];
The exception is to be expected, since -stringValue returns an
NSString, not an NSAttributedString. But even if you used -
attributedStringValue your code does nothing but leak memory, since
it's operating on a copy of the string and doesn't set the copy into
the control, and the string isn't being released.
There must be an easier way to set the text color on a NSButton.
Try -attributedStringValue, but what are you trying to accomplish?
Changing the color of a string in an NSButton seems a little bit non-
standard to me.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins (at) lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden