Cannot see appended AttributedString in NSTextView

When I appendAttributedString to [textView textStorage] it does not appear on the scrollable TextView. However when I NSLog the [textView textStorage] the Attributed string is outputted, and is therefore stored in the textView, see below.

Occurs every time I ask to see the AttributedString I send to the textView.

I need to see the attributedString displayed on the ScrollableTextView, but I don't know why I cannot see it.

Thanks for the post, very interesting. Can you provide the code that is causing that issue? I am not hitting this issue when I add a new string with

// What happens when you do this? 
DispatchQueue.main.async {
    self.textView.textStorage.append(attributedString)
}

https://developer.apple.com/documentation/uikit/uitextview/textstorage


UI updates should always be performed on the main thread. If you're appending attributed strings asynchronously, make sure to wrap your update code in a dispatch to the main queue. Double-check that you're modifying the correct instance. If there are multiple text views or if the text view is being recreated somewhere else in your code, modifications might be applied to the wrong instance.

Albert Pascual
  Worldwide Developer Relations.

Cannot see appended AttributedString in NSTextView
 
 
Q