title: Showing image from url with placeholder in UITextView with attributed string
body: <p>I'm developing lib for markdown with swift and it works fine! But there is a little problem, when I load images that are in markdown I put placeholder image and dispatch another process to load original image, like this:</p>
  
  <pre><code>var attachment: NSTextAttachment = NSTextAttachment()
  
              attachment.image = UIImage(named: "placeholder.png")
              attachment.bounds = CGRect(origin: CGPointZero, size: attachment.image.size.width &gt; UIScreen.mainScreen().bounds.width ? CGSizeMake(UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.width/attachment.image.size.width * attachment.image.size.height)  : attachment.image.size )
  
              dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { () -&gt; Void in
                  let imageData: NSData = NSData(contentsOfURL: url)
  
                  attachment.image = UIImage(data: imageData)
                  attachment.bounds = CGRect(origin: CGPointZero, size: attachment.image.size.width &gt; UIScreen.mainScreen().bounds.width ? CGSizeMake(UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.width/attachment.image.size.width * attachment.image.size.height)  : attachment.image.size )
                  self.textView.setNeedsDisplay()
              })
  
              let attributedString: NSAttributedString = NSAttributedString(attachment: attachment)
              let lineBreak: NSAttributedString = NSAttributedString(string: "\n")
  
              self.markdown.deleteCharactersInRange(matchRange)
  
              self.markdown.insertAttributedString(attributedString, atIndex: matchRange.location)
              self.markdown.insertAttributedString(lineBreak, atIndex: matchRange.location)
  </code></pre>
  
  <p>but after loading image place holder doesn't disappear until user start to scroll, suddenly correct image shown!</p>
  
  <p>So I am interested to know what's the problem?</p>