For the reference, this is what I got elsewhere:
Attachments are stored in the text storage as NSAttachmentCharacter with the attribute NSAttachmentAttributeName, whose value is the NSTextAttachment object. The NSTextAttachment in turn has the contents of the attached file (in its fileWrapper) and also a cell used to represent it visually (its attachmentCell). If the text system recognizes the file as an image file, then it will automatically create an appropriate attachment cell and assign to it an image created from that file. If the text system does not recognize the file format, then it will automatically create an appropriate attachment cell and assign to it a suitable icon image representing the file. What you should do depends on whether you are looking for the image or for the contents of the file.
One last question, how do I make a "NSRangePointer"?
