FROM : Jonathan Dann
DATE : Thu Jan 10 19:23:03 2008
> 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?
Even though your text view is bound to the NSMutableAttributedString,
I'm not sure that the method you give is KVO-compliant.
You may need [self setAttributedText:[[self attributedText]
replaceCharactersInRange:elementRangeWithString:[te c]]];
This is what the binding mechanism is looking for so it knows to
update your field, you have to update our model programmatically with
a setter or another KVO-compliant method.
As always, tell me if I'm wrong!
Jonathan
DATE : Thu Jan 10 19:23:03 2008
> 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?
Even though your text view is bound to the NSMutableAttributedString,
I'm not sure that the method you give is KVO-compliant.
You may need [self setAttributedText:[[self attributedText]
replaceCharactersInRange:elementRangeWithString:[te c]]];
This is what the binding mechanism is looking for so it knows to
update your field, you have to update our model programmatically with
a setter or another KVO-compliant method.
As always, tell me if I'm wrong!
Jonathan
| Related mails | Author | Date |
|---|---|---|
| Ivan C Myrvold | Jan 10, 18:11 | |
| Douglas Davidson | Jan 10, 18:28 | |
| Jonathan Dann | Jan 10, 19:23 | |
| Ivan C Myrvold | Jan 10, 20:28 | |
| Douglas Davidson | Jan 10, 20:32 |






Cocoa mail archive

