title: Adding an NSTextAttachment with an image to NSMutableAttributedString does not appear immediately
body: <p>I'm trying to add an image to an NSMutableAttributedString via NSTextAttachment, the trouble is that the image doesn't seem to appear until I restart the app. Any ideas? </p>
  
  <pre><code>var attributesForThisSection = [String : Any]()
  
  if key == NSAttachmentAttributeName {
  
      let base64Rep = (value as! String)
  
      if let data = Data(base64Encoded: base64Rep) {
  
          let textAttachment = NSTextAttachment()
          if let img = NSImage(data: data) {
              textAttachment.image = img
              attributesForThisSection[NSAttachmentAttributeName] = textAttachment
          }
          else {
              print("img from data not ok")
          }
  
      }
  
  }
  </code></pre>
  
  <p>Then</p>
  
  <pre><code>let r = NSMakeRange(loc, len)
  attributedString?.addAttributes(attributesForThisSection, range: r)
  </code></pre>
  
  <p>The text is displayed in an NSTextView, thanks!</p>