Re: NSMutableAttributedString binding
Re: NSMutableAttributedString binding
- Subject: Re: NSMutableAttributedString binding
- From: Douglas Davidson <email@hidden>
- Date: Thu, 10 Jan 2008 09:28:13 -0800
On Jan 10, 2008, at 9:11 AM, Ivan C Myrvold wrote:
I have binded the a NSTextView to an NSAttributedString. This works
fine when I set the binded variable, the NSTextView is showing the
text fine.
But if I make a change in the variable, this is not reflected in the
NSTextView.
I am doing this:
[[self attributedText] replaceCharactersInRange:elementRange
withString:[te c]];
and the NSTextView which is binded to attributedText does never show
the change.
If I do an NSLog of this variable immediately following the above
line, I can see the change.
What should I do to get the NSTextView to show the change?
This isn't a case for bindings, it's a case for using the text
system. Each NSTextView already has a mutable attributed string, its
text storage, and it listens for changes to the text storage
automatically. What you are doing is maintaining two separate copies
of the text, and trying to have the text entirely copied over after
each change, which would be inefficient. Look at the text system
documentation and see how to make changes to the text storage.
Douglas Davidson
_______________________________________________
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