• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to set the color of a string on a NSButton?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: How to set the color of a string on a NSButton?
      • From: David Hinz <email@hidden>
References: 
 >How to set the color of a string on a NSButton? (From: David Hinz <email@hidden>)

  • Prev by Date: How to set the color of a string on a NSButton?
  • Next by Date: Re: How to set the color of a string on a NSButton?
  • Previous by thread: How to set the color of a string on a NSButton?
  • Next by thread: Re: How to set the color of a string on a NSButton?
  • Index(es):
    • Date
    • Thread