• 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
NSAttributedString (How to use with NSTextField?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSAttributedString (How to use with NSTextField?)


  • Subject: NSAttributedString (How to use with NSTextField?)
  • From: Jeremy French <email@hidden>
  • Date: Sun, 9 Jan 2005 20:34:08 -0500

The book "Cocoa Programming for Mac OSX" (second edition) shows how to use an attributed string in a text field, so you can style the text. But when I try the example in the book, the style is not rendered.

Using the sample code from the book, I tried the following, which sets a large 36 pt font size:

- (void)awakeFromNib
{

  // code from book page 266

  s = [[NSMutableAttributedString alloc] initWithString:@"Big Nerd Ranch"];

  [s addAttribute:NSFontAttributeName
            value:[NSFont userFontOfSize:36]
            range:NSMakeRange(0,14)];

  // code from book page 267


  [textField setAttributedStringValue:s];
}

The text field displays "Big Nerd Ranch". However, the point size appears to be about 12 points.

I put a break point at the last line above. When the break point was reached, I typed the following in the Debugger Console:
--
po s
--


and the Console displayed the following:
--
Big Nerd Ranch{
  NSFont = "CGS Helvetica 36.00 pt. P [] (0x0053f870) fobj=0x0053c7c0, spc=10.00";
}
--


How do I get the text field to display the attributed string using the specified attributes (which in this case is 36 point size)?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: NSAttributedString (How to use with NSTextField?)
      • From: Ryan Stevens <email@hidden>
  • Prev by Date: Re: Tooltip-like view when dragging
  • Next by Date: Re: Bindings and 2 NSTableViews
  • Previous by thread: Re: Tooltip-like view when dragging
  • Next by thread: Re: NSAttributedString (How to use with NSTextField?)
  • Index(es):
    • Date
    • Thread