FROM : Gordon Apple
DATE : Fri May 30 17:13:35 2008
Yes, I did try mutable copy (which still required intercepting the
"text" key when copying the shape). It didn't help.
I inserted some test code to try to figure out why it was crashing my
program. The NSTextStorage, when copied, would blow up when asking for
layoutManagers. (I was trying to see if it had one by default.) So
something is not getting initialized in the copy.
Why NSTextStorage? Because that is what Sketch uses, and I lifted as
much code from there as I could, although I use my own Bezier text container
when rendering it. The floating NSTextView uses it directly. I suppose I
could change it to store NSMutableAttributedString and create the
NSTextStorage on-the-fly when rendering (and for the floating edit view).
Anyway, like I said, creating a new NSTextStorage, initialized with the
old storage, seems to have solved that problem, although I don't understand
why the problem just surfaced now.
>
> On 29 May '08, at 11:03 AM, Gordon Apple wrote:
>
>> Apparently, NSTextStorage does not conform to NSCopying, even
>> though its
>> superclass (NSAttributedString) does. Has something changed
>> recently with
>> NSTextStorage that makes "copy" not work?
>
> Is there a reason you need to use NSTextStorage instead of
> NSAttributedString? Generally the only place NSTextStorage is used is
> in the innards of NSTextViews.
>
> I'm not sure what -copy would do with an NSTextStorage, since it
> inherits from NSMutableAttributedString, and copying an
> NSMutableAttributedString returns an NSAttributedString. In other
> words, copying mutable objects returns immutable ones. Have you tried
> using -mutableCopy instead?
>
> ‹Jens
DATE : Fri May 30 17:13:35 2008
Yes, I did try mutable copy (which still required intercepting the
"text" key when copying the shape). It didn't help.
I inserted some test code to try to figure out why it was crashing my
program. The NSTextStorage, when copied, would blow up when asking for
layoutManagers. (I was trying to see if it had one by default.) So
something is not getting initialized in the copy.
Why NSTextStorage? Because that is what Sketch uses, and I lifted as
much code from there as I could, although I use my own Bezier text container
when rendering it. The floating NSTextView uses it directly. I suppose I
could change it to store NSMutableAttributedString and create the
NSTextStorage on-the-fly when rendering (and for the floating edit view).
Anyway, like I said, creating a new NSTextStorage, initialized with the
old storage, seems to have solved that problem, although I don't understand
why the problem just surfaced now.
>
> On 29 May '08, at 11:03 AM, Gordon Apple wrote:
>
>> Apparently, NSTextStorage does not conform to NSCopying, even
>> though its
>> superclass (NSAttributedString) does. Has something changed
>> recently with
>> NSTextStorage that makes "copy" not work?
>
> Is there a reason you need to use NSTextStorage instead of
> NSAttributedString? Generally the only place NSTextStorage is used is
> in the innards of NSTextViews.
>
> I'm not sure what -copy would do with an NSTextStorage, since it
> inherits from NSMutableAttributedString, and copying an
> NSMutableAttributedString returns an NSAttributedString. In other
> words, copying mutable objects returns immutable ones. Have you tried
> using -mutableCopy instead?
>
> ‹Jens
| Related mails | Author | Date |
|---|---|---|
| Gordon Apple | May 29, 20:03 | |
| Jens Alfke | May 30, 06:53 | |
| Gordon Apple | May 30, 17:13 | |
| Kyle Sluder | May 30, 22:16 | |
| Gordon Apple | Jun 1, 01:49 | |
| Ross Carter | Jun 1, 17:59 | |
| Gordon Apple | Jun 3, 17:15 | |
| Kyle Sluder | Jun 3, 18:51 | |
| Ross Carter | Jun 3, 20:19 | |
| Kyle Sluder | Jun 3, 22:21 | |
| Alastair Houghton | Jun 4, 00:09 | |
| Sherm Pendley | Jun 4, 10:14 |






Cocoa mail archive

