• 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: OK, but what do 'attributes' look like?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OK, but what do 'attributes' look like?


  • Subject: Re: OK, but what do 'attributes' look like?
  • From: mmalcolm crawford <email@hidden>
  • Date: Mon, 8 Mar 2004 22:45:43 -0800

On Mar 8, 2004, at 10:31 PM, mmalcolm crawford wrote:

"You can assign any attribute name/value pair you wish ". This doesn't make sense to me. Surely for the text to appear in a certain font I have to identify that font using a name that the compiler will recognise. Making up my own key value pair will not communicate anything useful.

It allows for flexibility -- suppose you wanted to mark up text with special attributes for class names. Apple hasn't provided an attribute for that, but you can create, and assign, your own...

To address the specific question, "Surely for the text to appear in a certain font I have to identify that font using a name that the compiler will recognise." -- to have text appear in a particular font, using the built-in attribute name for a font specifier, yes, you do have to use NSFontAttributeName. You can specify any other string you wish, but it won't give a compiler error. It will simply add that attribute to the string, with whatever value you provide. How, or whether, it's used later is up to you.

e.g.
[myString drawInRect: myRect withAttributes:
[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:8]
forKey: @"DayOfTheMonth"]];

won't give an error, it just won't do anything useful with the DayOfTheMonth attribute.

mmalc
_______________________________________________
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.


References: 
 >Re: OK, but what do 'attributes' look like? (From: Denis Stanton <email@hidden>)
 >Re: OK, but what do 'attributes' look like? (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: NSMutableArray morphs itself into an NSArray?
  • Next by Date: Re: OK, but what do 'attributes' look like?
  • Previous by thread: Re: OK, but what do 'attributes' look like?
  • Next by thread: Re: OK, but what do 'attributes' look like?
  • Index(es):
    • Date
    • Thread