Class

NSTextAttachment

NSTextAttachment objects are used by the NSAttributedString class cluster as the values for attachment attributes (stored in the attributed string under the key named NSAttachmentAttributeName). The objects you create with this class are referred to as text attachment objects, or when no confusion will result, as text attachments or merely attachments.

Overview

A text attachment object contains either an NSData object or an FileWrapper object, which in turn holds the contents of the attached file. The properties of this class configure the appearance of the text attachment in your interface. In macOS, the text attachment also uses a cell object conforming to the NSTextAttachmentCellProtocol protocol to draw and handle mouse events.

For more information about text attachments, see the NSAttributedString and NSTextView.

Symbols

Initializing an NSTextAttachment object

init(fileWrapper: FileWrapper?)

Initializes a newly allocated NSTextAttachment object to contain the given file wrapper.

init(data: Data?, ofType: String?)

Initializes a new NSTextAttachment object with the given data.

Defining the Contents

var bounds: CGRect

Defines the layout bounds of the receiver's graphical representation in the text coordinate system.

var contents: Data?

Defines the contents for the text attachment.

var fileType: String?

Defines the file type of the contents for the text attachment.

var image: UIImage?

Image representing the text attachment contents.

var fileWrapper: FileWrapper?

The receiver’s file wrapper.

Setting the attachment cell

var attachmentCell: NSTextAttachmentCellProtocol?

The object used to draw the icon for the receiver and to handle mouse events.

Constants

Attachment Character

This character is used to denote an attachment.