title: NSTextAttachment Image Disappears When Attributes Are Set
body: <p>I'm having trouble applying attributes to <code>NSMutableAttributedString</code>s. If they have an image attachment, the image goes away when the attributes get added.</p>
  
  <p>Take an <code>NSMutableAttributedString</code> that includes a text attachment, like this:</p>
  
  <pre><code>let myString = NSMutableAttributedString(string: "Hello\n\n")
  let attachment = NSTextAttachment()
  attachment.image = image    // some UIImage
  let attachmentString = NSAttributedString(attachment: attachment)
  myString.appendAttributedString(attachmentString)
  </code></pre>
  
  <p>If I try to apply an attribute to the string, I lose the attachment:</p>
  
  <pre><code>let bodyFont = UIFont.preferredFontForTextStyle(UIFontTextStyleBody)
  myString.setAttributes([NSFontAttributeName: bodyFont], 
                         range: NSMakeRange(0, myString.length))
  </code></pre>
  
  <p>The string now appears with the right font but the attachment is gone. If I make the range <code>myString.length - 1</code> the attachment persists so I could probably step around any attachments with a little more work (maybe by looking for <code>NSTextAttachmentCharacter</code>). I'm wondering if there's something simpler I'm missing.</p>