Manage text storage and perform custom layout of text-based content in your app's views.


TextKit provides a number of classes to control the layout of text, such as NSTextStorage, NSLayoutManager, and NSTextContainer.

Additionally, NSAttributedString objects are used extensively throughout TextKit. The NSTextStorage class is a subclass of NSMutableAttributedString, and many of the TextKit classes (for example, the classes listed in Formatted Content) focus on creating complex NSAttributedString instances. Use these classes to specify your text's format.

Most of the time, you can use TextKit to fine tune the formatting and layout of a NSTextView by modifying the view's textContainer, layoutManager, or textStorage properties. If you need more control, you can also use TextKit to build your own custom text controls.


Data Management

class NSTextStorage

The fundamental storage mechanism of TextKit.

protocol NSTextStorageDelegate

A set of optional methods implemented by delegates of NSTextStorage objects to handle text-edit processing.


class NSLayoutManager

An object that coordinates the layout and display of text characters.

protocol NSLayoutManagerDelegate

A set of optional methods implemented by delegates of layout manager objects.

class NSTextContainer

A region where text is laid out.

class NSATSTypesetter

A concrete typesetter object that places glyphs during the text layout process.

class NSTypesetter

An abstract class that performs various type layout tasks.

protocol NSTextLayoutOrientationProvider

A set of methods that define the orientation of text for an object.

Formatted Content

class NSTextBlock

A block of text laid out in a subregion of the text container.

class NSParagraphStyle

The paragraph or ruler attributes used by an attributed string.

class NSMutableParagraphStyle

An object that enables changing the values of the subattributes in a paragraph style attribute.

class NSTextTable

An object that represents a text table as a whole.

class NSTextTableBlock

A text block that appears as a cell in a text table.

class NSTextTab

A tab in an NSParagraphStyle object, storing an alignment type and location.

class NSTextList

A section of text that forms a single list.


class NSTextAttachment

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

class NSTextAttachmentCell

An object that implements the functionality of the text attachment cell protocol.

protocol NSTextAttachmentCellProtocol

A set of methods that declares the interface for objects that draw text attachment icons and handle mouse events on their icons.

protocol NSTextAttachmentContainer

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


typealias NSGlyph

The type used to specify glyphs.

protocol NSGlyphStorage

A set of methods that a glyph storage object must implement to interact properly with NSGlyphGenerator.

class NSGlyphGenerator

An object that performs the initial, nominal glyph generation phase in the layout process.

class NSGlyphInfo

A glyph attribute in an attributed string.

Glyph Attributes

Attributes that are used only inside the glyph generation machinery, but must also be shared between components.

Input Management

protocol NSTextInput

A set of methods that text views must implement to interact properly with the text input management system.

protocol NSTextInputClient

A set of methods that text views must implement to interact properly with the text input management system.

class NSTextInputContext

An object that represents the Cocoa text input system.

class NSTextAlternatives

A list of alternative strings for a piece of text.

See Also


Text Display

Display text and check spelling.


Manage the fonts used to display text.