A section of text that forms a single list.


class NSTextList : NSObject


The visible elements of the list, including list markers, appear in the text as they do for lists created by hand. The list object, however, allows the list to be recognized as such by the text system. This enables automatic creation of markers and spacing. Text lists are used in HTML import and export.

Text lists appear as attributes on paragraphs, as part of the paragraph style. An NSParagraphStyle may have an array of text lists, representing the nested lists containing the paragraph, in order from outermost to innermost. For example, if list1 contains four paragraphs, the middle two of which are also in the inner list2, then the text lists array for the first and fourth paragraphs is (list1), while the text lists array for the second and third paragraphs is (list1, list2).

The methods implementing this are textLists on NSParagraphStyle, and textLists on NSMutableParagraphStyle.

In addition, NSAttributedString has convenience methods for lists, such as range(of:at:), which determines the range covered by a list, and itemNumber(in:at:), which determines the ordinal position within a list of a particular item.


Creating a Text List

Working with Markers

var markerFormat: NSTextList.MarkerFormat

Returns the marker format string used by the receiver.

func marker(forItemNumber: Int) -> String

Returns the computed value for a specific ordinal position in the list.

Getting List Options

var listOptions: NSTextList.Options

Returns the list options mask value of the receiver.

Managing Item Numbering

var startingItemNumber: Int

Sets the starting item number for the text list.


The following constant specifies an option mask used with init(markerFormat:options:).

static var prependEnclosingMarker: NSTextList.Options

Specifies that a nested list should include the marker for its enclosing superlist before its own marker.


Inherits From

See Also

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.