Re: is this string styled?
Re: is this string styled?
- Subject: Re: is this string styled?
- From: Matt Neuburg <email@hidden>
- Date: Mon, 09 Jan 2006 09:54:44 -0800
- Thread-topic: is this string styled?
On Sat, 07 Jan 2006 06:57:33 -0800, Matt Neuburg <email@hidden> said:
>I have an NSTextView. To save storage space, if what's in the text view is
>effectively unstyled, I'd like to save just the NSString version of it, not
>the whole NSAttributedString. Is there a simple way to ask the
>NSAttributedString: "Are your attributes the same as what I'd get if I took
>your string, made an NSAttributedString from it using initWithString, and
>stuck it in that NSTextView?" (The reason I'm having trouble with this is
>that the attributes of an attributed string made with initWithString form an
>empty dictionary, but the attributes of that same attributed string when it
>has passed thru the text view are no longer empty.) m.
Just to follow up: I was able to cobble together a working method by making
an NSTextStorage, stuffing a space character into it, and reading its
attributesAtIndex. These are the application's "default attributes".
However, I remain somewhat surprised by the difficulty of comparing two
attribute dictionaries. The trouble seems to lie in the fact that, as far as
I can tell, NSFont does not obey isEqual. Given two NSFont instances whose
descriptions are identical, the two NSFont instances are not, themselves,
reported as equal. Therefore, comparison of the attribute dictionaries
fails: two identical NSAttributedStrings are not reported as having the same
attribute dictionary.
I can work around the problem by examine the attribute dictionaries myself,
comparing the values for each key, and in particular, for the "font" key,
comparing the descriptions of the NSFonts rather than the actual values. But
surely I should not have to do this? Is NSFont's failure to respond
correctly to isEqual a bug? m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
_______________________________________________
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