Yes, working through the NSTextStorage is the way to go. To replace its entire contents you can use -replaceCharactersInRange:withAttributedString: <https://developer.apple.com/documentation/foundation/nsmutableattributedstring/1417045-replacecharactersinrange> with a range that encompasses all current text.
You should not need to manually call -setNeedsDisplay: on the NSTextView as was suggested earlier. If you're working with the right NSTextStorage then its view should observe the changes and automatically mark any redisplay as needed. ~Martin Wierschin > On Feb 02, 2020, at 3:01 PM, Jonathan Prescott via Cocoa-dev > <cocoa-dev@lists.apple.com> wrote: > > Looking at the documentation for NSTextView, it is highly recommended that > you manipulate the NSTextStorage associated with the view. NSTextStorage is > a sub-class of NSMutableAttributedtString, so you have all of those > capabilities as well. > > I’m just getting into this as well for my console application related to my > expert system interface. > > Jonathan > >> On Feb 2, 2020, at 3:37 PM, Jeff Younker <j...@drinktomi.com> wrote: >> >> Yes, I've set needsDisplay = true in my attempts to so far. Also needsLayout >> = true. >> >> The question I've got though is what is the recommended way of setting the >> value to T2. There is no attributedString variable, just an accessor method, >> so I've been trying a variety of insert methods. >> >> -jeff >> >> On Sun, Feb 2, 2020 at 12:19 PM Jonathan Prescott <jprescot...@icloud.com >> <mailto:jprescot...@icloud.com>> wrote: >> Did you tell V that it needs to re-load it’s display? There is a method on >> NSView (from which NSTextView is derived) called “needsDisplay(sic)” which >> sets a flag on the view so that the view will re-draw its content the next >> display cycle. So, after you set the content to T2, you need to call >> “V.needsDisplay()” so that the next display cycle the view gets refreshed. >> Need to check the spelling of the method. >> >> Jonathan > > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/martin%40nisus.com > > This email sent to mar...@nisus.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com