Re: OK, but what do 'attributes' look like?
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.