• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSMutableAttributedString binding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableAttributedString binding


  • Subject: Re: NSMutableAttributedString binding
  • From: Jonathan Dann <email@hidden>
  • Date: Thu, 10 Jan 2008 18:23:03 +0000

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
_______________________________________________

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


  • Prev by Date: Re: Setting spell-checker underlines
  • Next by Date: Re: Property List Serialization in Sketch
  • Previous by thread: Re: NSMutableAttributedString binding
  • Next by thread: Drag and Drop from Finder to Source List
  • Index(es):
    • Date
    • Thread