Class

NSTextAttachment

The values for the attachment attributes of attributed strings and related objects.

Declaration

@interface NSTextAttachment : NSObject

Overview

The NSAttributedString class cluster uses text attachment objects as the values for attachment attributes (stored in the attributed string under the key named NSAttachmentAttributeName).

A text attachment object contains either an NSData object or an NSFileWrapper 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 NSTextAttachmentCell protocol to draw and handle mouse events.

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

Topics

Initializing an NSTextAttachment object

- initWithFileWrapper:

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

- initWithData:ofType:

Initializes a new NSTextAttachment object with the given data.

Defining the Contents

bounds

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

contents

Defines the contents for the text attachment.

fileType

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

image

Image representing the text attachment contents.

fileWrapper

The receiver’s file wrapper.

Setting the attachment cell

attachmentCell

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

Constants

Attachment Character

A character that denotes an attachment.

Relationships

Inherits From

See Also

Attachments

NSTextAttachmentContainer

A set of methods that defines the interface to text attachment objects from NSLayoutManager.