I am declaring an NSMutable Attributed String and appending different attributed strings to it. These attributed string may contain images as NSTextattachments.
var historyText : NSMutableAttributedString = NSMutableAttributedString(string: "")
let imageAttachment = NSTextAttachment()
imageAttachment.image = UIImage(named: "some_image")
imageAttachment.bounds = CGRect(x:0, y:-3.0, width: (imageAttachment.image?.size.width)!, height:(imageAttachment.image?.size.height)!)
let imageString = NSAttributedString(attachment: imageAttachment)
historyText.append(imageString)
I then save this attributed text in core data. But when i retrieve this attributed text from core data, the imageAttachment.bounds are lost. Please suggest a way to preserve these bounds. Thanks in advance.