Re: NSForegroundColorAttributeName without AppKit
Re: NSForegroundColorAttributeName without AppKit
- Subject: Re: NSForegroundColorAttributeName without AppKit
- From: Ken Ferry <email@hidden>
- Date: Mon, 1 Mar 2010 21:00:49 -0800
On Mon, Mar 1, 2010 at 7:51 PM, Graham Cox <email@hidden> wrote:
>
> On 02/03/2010, at 2:39 PM, Steven Degutis wrote:
>
> > NSAttributedString is part of Foundation.framework and so are all
> NSStrings
> > (including literal constants like @"NSColor"). Thus, you can use that
> safely
> > without linking against AppKit.framework; however, I advise against using
> > string literals in place of Apple's constants, since they might change
> under
> > your nose.
>
>
> It's a good idea to use the constant where possible, but Apple couldn't
> just change it without breaking binary compatibility, so it should be safe
> to use the literal @"NSColor" in this case, if the constant itself is
> defined in AppKit.
>
When you use a symbol like NSForegroundColorAttributeName, a reference to
the symbol is embedded in your binary, not the value. So it could possibly
change.
Barriers to this would be (1) people persisting attribute dictionaries, (2)
IPC between processes with the symbol defined differently. (2) doesn't seem
that likely to occur. (1) might, it's hard to say.
-Ken
>> Unfortunately it seems that using the @"NSColor" key as part of an
> >> NSAttributedString also requires AppKit. Put another way, I can't see
> any
> >> way to draw multi-colored text in a wrapping text field without using
> >> AppKit.
> >
>
> Yes, all the attributed string DRAWING functions are in AppKit, but so is
> NSTextField. Foundation provides the existence of NSAttributedString (the
> data model, if you like) but not the view or UI related aspects of it.
>
> --Graham
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please 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
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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