• 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
I can get an NSFont attribute from an NSAttributedString, but not an NSColor attribute.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

I can get an NSFont attribute from an NSAttributedString, but not an NSColor attribute.


  • Subject: I can get an NSFont attribute from an NSAttributedString, but not an NSColor attribute.
  • From: Mark Ogilvie <email@hidden>
  • Date: Sat, 26 Apr 2003 17:01:03 -0400

It's puzzling. I've been working with the NSAttributedString example,
and I've been able to get the name of the current NSFont in use by an
individual character using this code. i is the current number in a
for-loop, range is NSMakeRange (letterCount, 0)

// get the font that the letter is using
fontName = [[attributedStringFromSourceText
attribute:NSFontAttributeName

atIndex:letterCount

effectiveRange:&letterRange] fontName];
with fontName returning an NSString and the font being assigned to the
NSString fontName variable. But when I try to do the same to get the
color of the individual letter using this

// get the color that the letter is using
colorName = [[attributedStringFromSourceText
attribute:NSForegroundColorAttributeName
atIndex:i

effectiveRange:&letterRange] colorNameComponent];

it comes up as invalid in the debugger with a null value when I print
out the description.

NSForegroundColorAttributeName is the attributed identifier in the
documentation, and using colorNameComponent should return a string of
the colors name. I've tested this with different colors and just
leaving the text black, but no luck. What is the difference between
the NSFont attribute name and the NSColor attribute name? Does
NSForegroundColorAttributeName return an NSColor object that can not be
translated into a string by colorNameComponent?

Thanks

Mark



http://members.ttlc.net/~mso/WebPage1.html
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Illegal reference
  • Next by Date: NSThread as a wrapper
  • Previous by thread: Re: Illegal reference
  • Next by thread: NSThread as a wrapper
  • Index(es):
    • Date
    • Thread