Strings and Text

Create and process strings of Unicode characters, use regular expressions to find patterns, and perform natural language analysis of text.



struct String

A Unicode string value that is a collection of characters.

Strings with Metadata

class NSAttributedString

A string that has associated attributes (such as visual style, hyperlinks, or accessibility data) for portions of its text.

class NSMutableAttributedString

A mutable string object that also contains attributes (such as visual style, hyperlinks, or accessibility data) associated with various portions of its text content.


struct CharacterSet

A set of Unicode character values for use in search operations.

Natural Language Processing

class NSLinguisticTagger

Analyze natural language text to tag part of speech and lexical class, identify names, perform lemmatization, and determine the language and script.

Pattern Matching

class Scanner

An abstract superclass of a class cluster that scans values from a string.

class NSRegularExpression

An immutable representation of a compiled regular expression that you apply to Unicode strings.

class NSDataDetector

A specialized regular expression object that matches natural language text for predefined data patterns.

class NSTextCheckingResult

An occurrence of textual content found during the analysis of a block of text, such as when matching a regular expression.

let NSNotFound: Int

A value indicating that a requested item couldn’t be found or doesn’t exist.

Spelling and Grammar

class NSSpellServer

A server that your app uses to provide a spell checker service to other apps running in the system.

protocol NSSpellServerDelegate

The optional methods implemented by the delegate of a spell server.


struct Locale

Information about linguistic, cultural, and technological conventions for use in formatting data for presentation.

class NSOrthography

A description of the linguistic content of a piece of text typically used for spelling and grammar checking.

func NSLocalizedString(String, tableName: String?, bundle: Bundle, value: String, comment: String)

Returns a localized string, using the main bundle if one is not specified.

See Also


Numbers, Data, and Basic Values

Work with primitive values and other fundamental types used throughout Cocoa.


Use arrays, dictionaries, sets, and specialized collections to store and iterate groups of objects or values.

Dates and Times

Compare dates and times, and perform calendar and time zone calculations.

Units and Measurement

Label numeric quantities with physical dimensions to allow locale-aware formatting and conversion between related units.

Data Formatting

Convert numbers, dates, measurements, and other values to and from locale-aware string representations.

Filters and Sorting

Use predicates, expressions, and sort descriptors to examine elements in collections and other services.