Class

NSString

The NSString class and its mutable subclass, NSMutable​String, provide an extensive set of APIs for working with strings, including methods for comparing, searching, and modifying strings. NSString objects are used throughout Foundation and other Cocoa frameworks, serving as the basis for all textual and linguistic functionality on the platform.

Overview

NSString is “toll-free bridged” with its Core Foundation counterpart, CFString. See “Toll-Free Bridging” for more information.

String Objects

An NSString object encodes a Unicode-compliant text string, represented as a sequence of UTF–16 code units. All lengths, character indexes, and ranges are expressed in terms of 16-bit platform-endian values, with index values starting at 0.

An NSString object can be initialized from or written to a C buffer, an NSData object, or the contents of an NSURL. It can also be encoded and decoded to and from ASCII, UTF–8, UTF–16, UTF–32, or any other string encoding represented by NSString​Encoding.

The objects you create using NSString and NSMutable​String are referred to as string objects (or, when no confusion will result, merely as strings). The term C string refers to the standard char * type. Because of the nature of class clusters, string objects aren’t actual instances of the NSString or NSMutable​String classes but of one of their private subclasses. Although a string object’s class is private, its interface is public, as declared by these abstract superclasses, NSString and NSMutable​String. The string classes adopt the NSCopying and NSMutable​Copying protocols, making it convenient to convert a string of one type to the other.

Understanding Characters

A string object presents itself as a sequence of UTF–16 code units. You can determine how many UTF-16 code units a string object contains with the length method and can retrieve a specific UTF-16 code unit with the character(at:​) method. These two “primitive” methods provide basic access to a string object.

Most use of strings, however, is at a higher level, with the strings being treated as single entities: You compare strings against one another, search them for substrings, combine them into new strings, and so on. If you need to access string objects character by character, you must understand the Unicode character encoding, specifically issues related to composed character sequences. For details see The Unicode Standard, Version 4.0 (The Unicode Consortium, Boston: Addison-Wesley, 2003, ISBN 0-321-18578-1) and the Unicode Consortium web site: http://www.unicode.org/. See also Characters and Grapheme Clusters in String Programming Guide.

Localized string comparisons are based on the Unicode Collation Algorithm, as tailored for different languages by CLDR (Common Locale Data Repository). Both are projects of the Unicode Consortium. Unicode is a registered trademark of Unicode, Inc.

Interpreting UTF-16-Encoded Data

When creating an NSString object from a UTF-16-encoded string (or a byte stream interpreted as UTF-16), if the byte order is not otherwise specified, NSString assumes that the UTF-16 characters are big-endian, unless there is a BOM (byte-order mark), in which case the BOM dictates the byte order. When creating an NSString object from an array of unichar values, the returned string is always native-endian, since the array always contains UTF–16 code units in native byte order.

Subclassing Notes

It is possible to subclass NSString (and NSMutable​String), but doing so requires providing storage facilities for the string (which is not inherited by subclasses) and implementing two primitive methods. The abstract NSString and NSMutable​String classes are the public interface of a class cluster consisting mostly of private, concrete classes that create and return a string object appropriate for a given situation. Making your own concrete subclass of this cluster imposes certain requirements (discussed in Methods to Override).

Make sure your reasons for subclassing NSString are valid. Instances of your subclass should represent a string and not something else. Thus the only attributes the subclass should have are the length of the character buffer it’s managing and access to individual characters in the buffer. Valid reasons for making a subclass of NSString include providing a different backing store (perhaps for better performance) or implementing some aspect of object behavior differently, such as memory management. If your purpose is to add non-essential attributes or metadata to your subclass of NSString, a better alternative would be object composition (see Alternatives to Subclassing). Cocoa already provides an example of this with the NSAttributed​String class.

Methods to Override

Any subclass of NSString must override the primitive instance methods length and character(at:​). These methods must operate on the backing store that you provide for the characters of the string. For this backing store you can use a static array, a dynamically allocated buffer, a standard NSString object, or some other data type or mechanism. You may also choose to override, partially or fully, any other NSString method for which you want to provide an alternative implementation. For example, for better performance it is recommended that you override get​Characters(_:​range:​) and give it a faster implementation.

You might want to implement an initializer for your subclass that is suited to the backing store that the subclass is managing. The NSString class does not have a designated initializer, so your initializer need only invoke the init() method of super. The NSString class adopts the NSCopying, NSMutable​Copying, and NSCoding protocols; if you want instances of your own custom subclass created from copying or coding, override the methods in these protocols.

Alternatives to Subclassing

Often a better and easier alternative to making a subclass of NSString—or of any other abstract, public class of a class cluster, for that matter—is object composition. This is especially the case when your intent is to add to the subclass metadata or some other attribute that is not essential to a string object. In object composition, you would have an NSString object as one instance variable of your custom class (typically a subclass of NSObject) and one or more instance variables that store the metadata that you want for the custom object. Then just design your subclass interface to include accessor methods for the embedded string object and the metadata.

If the behavior you want to add supplements that of the existing class, you could write a category on NSString. Keep in mind, however, that this category will be in effect for all instances of NSString that you use, and this might have unintended consequences.

Nested Types

NSString.Enumeration​Options

Constants to specify kinds of substrings and styles of enumeration.

NSString.Encoding​Conversion​Options

Options for converting string encodings.

NSString.Compare​Options

These values represent the options available to many of the string classes’ search and comparison methods.

Symbols

Creating and Initializing Strings

init()

Returns an initialized NSString object that contains no characters.

init?(bytes:​ Unsafe​Raw​Pointer, length:​ Int, encoding:​ UInt)

Returns an initialized NSString object containing a given number of bytes from a given buffer of bytes interpreted in a given encoding.

init?(bytes​No​Copy:​ Unsafe​Mutable​Raw​Pointer, length:​ Int, encoding:​ UInt, free​When​Done:​ Bool)

Returns an initialized NSString object that contains a given number of bytes from a given buffer of bytes interpreted in a given encoding, and optionally frees the buffer.

init(characters:​ Unsafe​Pointer<unichar>, length:​ Int)

Returns an initialized NSString object that contains a given number of characters from a given C array of UTF-16 code units.

init(characters​No​Copy:​ Unsafe​Mutable​Pointer<unichar>, length:​ Int, free​When​Done:​ Bool)

Returns an initialized NSString object that contains a given number of characters from a given C array of UTF-16 code units.

init(string:​ String)

Returns an NSString object initialized by copying the characters from another given string.

init?(c​String:​ Unsafe​Pointer<Int8>, encoding:​ UInt)

Returns an NSString object initialized using the characters in a given C array, interpreted according to a given encoding.

init?(utf8String:​ Unsafe​Pointer<Int8>)

Returns an NSString object initialized by copying the characters from a given C array of UTF8-encoded bytes.

init(format:​ String, arguments:​ CVa​List​Pointer)

Returns an NSString object initialized by using a given format string as a template into which the remaining argument values are substituted without any localization. This method is meant to be called from within a variadic function, where the argument list will be available.

init(format:​ String, locale:​ Any?, arguments:​ CVa​List​Pointer)

Returns an NSString object initialized by using a given format string as a template into which the remaining argument values are substituted according to given locale information. This method is meant to be called from within a variadic function, where the argument list will be available.

init?(data:​ Data, encoding:​ UInt)

Returns an NSString object initialized by converting given data into UTF-16 code units using a given encoding.

class func localized​User​Notification​String(for​Key:​ String, arguments:​ [Any]?)

Returns a localized string intended for display in a notification alert.

Creating and Initializing a String from a File

init(contents​Of​File:​ String, encoding:​ UInt)

Returns an NSString object initialized by reading data from the file at a given path using a given encoding.

init(contents​Of​File:​ String, used​Encoding:​ Unsafe​Mutable​Pointer<UInt>?)

Returns an NSString object initialized by reading data from the file at a given path and returns by reference the encoding used to interpret the characters.

Creating and Initializing a String from an URL

init(contents​Of:​ URL, encoding:​ UInt)

Returns an NSString object initialized by reading data from a given URL interpreted using a given encoding.

init(contents​Of:​ URL, used​Encoding:​ Unsafe​Mutable​Pointer<UInt>?)

Returns an NSString object initialized by reading data from a given URL and returns by reference the encoding used to interpret the data.

Writing to a File or URL

func write(to​File:​ String, atomically:​ Bool, encoding:​ UInt)

Writes the contents of the receiver to a file at a given path using a given encoding.

func write(to:​ URL, atomically:​ Bool, encoding:​ UInt)

Writes the contents of the receiver to the URL specified by url using the specified encoding.

Getting a String’s Length

var length:​ Int

The number of UTF-16 code units in the receiver.

func length​Of​Bytes(using:​ UInt)

Returns the number of bytes required to store the receiver in a given encoding.

func maximum​Length​Of​Bytes(using:​ UInt)

Returns the maximum number of bytes needed to store the receiver in a given encoding.

Getting C Strings

func c​String(using:​ UInt)

Returns a representation of the receiver as a C string using a given encoding.

func get​CString(Unsafe​Mutable​Pointer<Int8>, max​Length:​ Int, encoding:​ UInt)

Converts the receiver’s content to a given encoding and stores them in a buffer.

var utf8String:​ Unsafe​Pointer<Int8>?

A null-terminated UTF8 representation of the string.

Identifying and Comparing Strings

func case​Insensitive​Compare(String)

Returns the result of invoking compare(_:​options:​) with NSCase​Insensitive​Search as the only option.

func localized​Case​Insensitive​Compare(String)

Compares the string with a given string using a case-insensitive, localized, comparison.

func compare(String)

Returns the result of invoking compare(_:​options:​range:​) with no options and the receiver’s full extent as the range.

func localized​Compare(String)

Compares the string and a given string using a localized comparison.

func compare(String, options:​ NSString.Compare​Options = [])

Compares the string with the specified string using the given options.

func compare(String, options:​ NSString.Compare​Options = [], range:​ NSRange, locale:​ Any?)

Compares the string using the specified options and returns the lexical ordering for the range.

func localized​Standard​Compare(String)

Compares strings as sorted by the Finder.

func has​Prefix(String)

Returns a Boolean value that indicates whether a given string matches the beginning characters of the receiver.

func has​Suffix(String)

Returns a Boolean value that indicates whether a given string matches the ending characters of the receiver.

func is​Equal(to:​ String)

Returns a Boolean value that indicates whether a given string is equal to the receiver using a literal Unicode-based comparison.

var hash:​ Int

An unsigned integer that can be used as a hash table address.

Combining Strings

func appending(String)

Returns a new string made by appending a given string to the receiver.

func padding(to​Length:​ Int, with​Pad:​ String, starting​At:​ Int)

Returns a new string formed from the receiver by either removing characters from the end, or by appending as many occurrences as necessary of a given pad string.

Dividing Strings

func components(separated​By:​ String)

Returns an array containing substrings from the receiver that have been divided by a given separator.

func components(separated​By:​ Character​Set)

Returns an array containing substrings from the receiver that have been divided by characters in a given set.

func trimming​Characters(in:​ Character​Set)

Returns a new string made by removing from both ends of the receiver characters contained in a given character set.

func substring(from:​ Int)

Returns a new string containing the characters of the receiver from the one at a given index to the end.

func substring(with:​ NSRange)

Returns a string object containing the characters of the receiver that lie within a given range.

func substring(to:​ Int)

Returns a new string containing the characters of the receiver up to, but not including, the one at a given index.

Finding Characters and Substrings

func contains(String)

Returns whether the receiver contains a given string by performing a case-sensitive, locale-unaware search.

func localized​Case​Insensitive​Contains(String)

Returns whether the receiver contains a given string by performing a case-insensitive, locale-aware search.

func localized​Standard​Contains(String)

Returns whether the receiver contains a given string by performing a case and diacritic insensitive, locale-aware search.

func range​Of​Character(from:​ Character​Set)

Finds and returns the range in the receiver of the first character from a given character set.

func range​Of​Character(from:​ Character​Set, options:​ NSString.Compare​Options = [])

Finds and returns the range in the receiver of the first character, using given options, from a given character set.

func range​Of​Character(from:​ Character​Set, options:​ NSString.Compare​Options = [], range:​ NSRange)

Finds and returns the range in the receiver of the first character from a given character set found in a given range with given options.

func range(of:​ String)

Finds and returns the range of the first occurrence of a given string within the receiver.

func range(of:​ String, options:​ NSString.Compare​Options = [])

Finds and returns the range of the first occurrence of a given string within the receiver, subject to given options.

func range(of:​ String, options:​ NSString.Compare​Options = [], range:​ NSRange)

Finds and returns the range of the first occurrence of a given string, within the given range of the receiver, subject to given options.

func range(of:​ String, options:​ NSString.Compare​Options = [], range:​ NSRange, locale:​ Locale?)

Finds and returns the range of the first occurrence of a given string within a given range of the receiver, subject to given options, using the specified locale, if any.

func localized​Standard​Range(of:​ String)

Finds and returns the range of the first occurrence of a given string within the receiver by performing a case and diacritic insensitive, locale-aware search.

Replacing Substrings

func replacing​Occurrences(of:​ String, with:​ String)

Returns a new string in which all occurrences of a target string in the receiver are replaced by another given string.

func replacing​Occurrences(of:​ String, with:​ String, options:​ NSString.Compare​Options = [], range:​ NSRange)

Returns a new string in which all occurrences of a target string in a specified range of the receiver are replaced by another given string.

func replacing​Characters(in:​ NSRange, with:​ String)

Returns a new string in which the characters in a specified range of the receiver are replaced by a given string.

Determining Line and Paragraph Ranges

func line​Range(for:​ NSRange)

Returns the range of characters representing the line or lines containing a given range.

func get​Paragraph​Start(Unsafe​Mutable​Pointer<Int>?, end:​ Unsafe​Mutable​Pointer<Int>?, contents​End:​ Unsafe​Mutable​Pointer<Int>?, for:​ NSRange)

Returns by reference the beginning of the first paragraph and the end of the last paragraph touched by the given range.

func paragraph​Range(for:​ NSRange)

Returns the range of characters representing the paragraph or paragraphs containing a given range.

Determining Composed Character Sequences

func range​Of​Composed​Character​Sequence(at:​ Int)

Returns the range in the receiver of the composed character sequence located at a given index.

func range​Of​Composed​Character​Sequences(for:​ NSRange)

Returns the range in the string of the composed character sequences for a given range.

Converting String Contents Into a Property List

func property​List()

Parses the receiver as a text representation of a property list, returning an NSString, NSData, NSArray, or NSDictionary object, according to the topmost element.

func property​List​From​Strings​File​Format()

Returns a dictionary object initialized with the keys and values found in the receiver.

Drawing Strings

func draw(at:​ CGPoint, with​Attributes:​ [String :​ Any]? = nil)

Draws the receiver with the font and other display characteristics of the given attributes, at the specified point in the current graphics context.

func draw(in:​ CGRect, with​Attributes:​ [String :​ Any]? = nil)

Draws the attributed string inside the specified bounding rectangle.

func bounding​Rect(with:​ CGSize, options:​ NSString​Drawing​Options = [], attributes:​ [String :​ Any]? = nil, context:​ NSString​Drawing​Context?)

Calculates and returns the bounding rect for the receiver drawn using the given options and display characteristics, within the specified rectangle in the current graphics context.

func size(attributes:​ [String :​ Any]? = nil)

Returns the bounding box size the receiver occupies when drawn with the given attributes.

Folding Strings

func folding(options:​ NSString.Compare​Options = [], locale:​ Locale?)

Returns a string with the given character folding options applied.

Getting a Shared Prefix

func common​Prefix(with:​ String, options:​ NSString.Compare​Options = [])

Returns a string containing characters the receiver and a given string have in common, starting from the beginning of each up to the first characters that aren’t equivalent.

Changing Case

var lowercased:​ String

A lowercase representation of the string.

var localized​Lowercase:​ String

Returns a version of the string with all letters converted to lowercase, taking into account the current locale.

func lowercased(with:​ Locale?)

Returns a version of the string with all letters converted to lowercase, taking into account the specified locale.

var uppercased:​ String

An uppercase representation of the string.

var localized​Uppercase:​ String

Returns a version of the string with all letters converted to uppercase, taking into account the current locale.

func uppercased(with:​ Locale?)

Returns a version of the string with all letters converted to uppercase, taking into account the specified locale.

var capitalized:​ String

A capitalized representation of the receiver.

var localized​Capitalized:​ String

Returns a capitalized representation of the receiver using the current locale.

func capitalized(with:​ Locale?)

Returns a capitalized representation of the receiver using the specified locale.

Getting Strings with Mapping

var decomposed​String​With​Canonical​Mapping:​ String

A string made by normalizing the string’s contents using the Unicode Normalization Form D.

var decomposed​String​With​Compatibility​Mapping:​ String

A string made by normalizing the receiver’s contents using the Unicode Normalization Form KD.

var precomposed​String​With​Canonical​Mapping:​ String

A string made by normalizing the string’s contents using the Unicode Normalization Form C.

var precomposed​String​With​Compatibility​Mapping:​ String

A string made by normalizing the receiver’s contents using the Unicode Normalization Form KC.

Getting Numeric Values

var double​Value:​ Double

The floating-point value of the string as a double.

var float​Value:​ Float

The floating-point value of the string as a float.

var int​Value:​ Int32

The integer value of the string.

var integer​Value:​ Int

The NSInteger value of the string.

var long​Long​Value:​ Int64

The long long value of the string.

var bool​Value:​ Bool

The Boolean value of the string.

Working with Encodings

class var available​String​Encodings:​ Unsafe​Pointer<UInt>

Returns a zero-terminated list of the encodings string objects support in the application’s environment.

class var default​CString​Encoding:​ UInt

Returns the C-string encoding assumed for any method accepting a C string as an argument.

class func localized​Name(of:​ UInt)

Returns a human-readable string giving the name of a given encoding.

func can​Be​Converted(to:​ UInt)

Returns a Boolean value that indicates whether the receiver can be converted to a given encoding without loss of information.

func data(using:​ UInt)

Returns an NSData object containing a representation of the receiver encoded using a given encoding.

func data(using:​ UInt, allow​Lossy​Conversion:​ Bool)

Returns an NSData object containing a representation of the receiver encoded using a given encoding.

var description:​ String

This NSString object.

var fastest​Encoding:​ UInt

The fastest encoding to which the receiver may be converted without loss of information.

var smallest​Encoding:​ UInt

The smallest encoding to which the receiver can be converted without loss of information.

Working with Paths

class func path(with​Components:​ [String])

Returns a string built from the strings in a given array by concatenating them with a path separator between each pair.

var path​Components:​ [String]

The file-system path components of the receiver.

func complete​Path(into:​ Autoreleasing​Unsafe​Mutable​Pointer<NSString?>?, case​Sensitive:​ Bool, matches​Into:​ Autoreleasing​Unsafe​Mutable​Pointer<NSArray?>?, filter​Types:​ [String]?)

Interprets the receiver as a path in the file system and attempts to perform filename completion, returning a numeric value that indicates whether a match was possible, and by reference the longest path that matches the receiver.

var file​System​Representation:​ Unsafe​Pointer<Int8>

A file system-specific representation of the receiver.

func get​File​System​Representation(Unsafe​Mutable​Pointer<Int8>, max​Length:​ Int)

Interprets the receiver as a system-independent path and fills a buffer with a C-string in a format and encoding suitable for use with file-system calls.

var is​Absolute​Path:​ Bool

A Boolean value that indicates whether the receiver represents an absolute path.

var last​Path​Component:​ String

The last path component of the receiver.

var path​Extension:​ String

The path extension, if any, of the string as interpreted as a path.

var abbreviating​With​Tilde​In​Path:​ String

A new string that replaces the current home directory portion of the current path with a tilde (~) character.

func appending​Path​Component(String)

Returns a new string made by appending to the receiver a given string.

func appending​Path​Extension(String)

Returns a new string made by appending to the receiver an extension separator followed by a given extension.

var deleting​Last​Path​Component:​ String

A new string made by deleting the last path component from the receiver, along with any final path separator.

var deleting​Path​Extension:​ String

A new string made by deleting the extension (if any, and only the last) from the receiver.

var expanding​Tilde​In​Path:​ String

A new string made by expanding the initial component of the receiver to its full path value.

var resolving​Symlinks​In​Path:​ String

A new string made from the receiver by resolving all symbolic links and standardizing path.

var standardizing​Path:​ String

A new string made by removing extraneous path components from the receiver.

func strings(by​Appending​Paths:​ [String])

Returns an array of strings made by separately appending to the receiver each string in in a given array.

Working with URLs

func adding​Percent​Encoding(with​Allowed​Characters:​ Character​Set)

Returns a new string made from the receiver by replacing all characters not in the specified set with percent-encoded characters.

var removing​Percent​Encoding:​ String?

Returns a new string made from the receiver by replacing all percent encoded sequences with the matching UTF-8 characters.

Deprecated

class func string(with​CString:​ Unsafe​Pointer<Int8>)

Creates a new string using a given C-string.

Deprecated
init?(c​String:​ Unsafe​Pointer<Int8>)

Initializes the receiver, a newly allocated NSString object, by converting the data in a given C-string from the default C-string encoding into the Unicode character encoding.

Deprecated
class func string(with​CString:​ Unsafe​Pointer<Int8>, length:​ Int)

Returns a string containing the characters in a given C-string.

Deprecated
init?(c​String:​ Unsafe​Pointer<Int8>, length:​ Int)

Initializes the receiver, a newly allocated NSString object, by converting the data in a given C-string from the default C-string encoding into the Unicode character encoding.

Deprecated
init?(c​String​No​Copy:​ Unsafe​Mutable​Pointer<Int8>, length:​ Int, free​When​Done:​ Bool)

Initializes the receiver, a newly allocated NSString object, by converting the data in a given C-string from the default C-string encoding into the Unicode character encoding.

Deprecated
class func string(with​Contents​Of​File:​ String)

Returns a string created by reading data from the file named by a given path.

Deprecated
init?(contents​Of​File:​ String)

Initializes the receiver, a newly allocated NSString object, by reading data from the file named by path.

Deprecated
class func string(with​Contents​Of:​ URL)

Returns a string created by reading data from the file named by a given URL.

Deprecated
init?(contents​Of:​ URL)

Initializes the receiver, a newly allocated NSString object, by reading data from the location named by a given URL.

Deprecated
func write(to​File:​ String, atomically:​ Bool)

Writes the contents of the receiver to the file specified by a given path.

Deprecated
func write(to:​ URL, atomically:​ Bool)

Writes the contents of the receiver to the location specified by a given URL.

Deprecated
func get​Characters(Unsafe​Mutable​Pointer<unichar>)

Copies all characters from the receiver into a given buffer.

Deprecated
func c​String()

Returns a representation of the receiver as a C string in the default C-string encoding.

Deprecated
func lossy​CString()

Returns a representation of the receiver as a C string in the default C-string encoding, possibly losing information in converting to that encoding.

Deprecated
func c​String​Length()

Returns the length in char-sized units of the receiver’s C-string representation in the default C-string encoding.

Deprecated
func get​CString(Unsafe​Mutable​Pointer<Int8>)

Invokes get​CString(_:​max​Length:​range:​remaining:​) with NSMaximum​String​Length as the maximum length, the receiver’s entire extent as the range, and NULL for the remaining range.

Deprecated
func get​CString(Unsafe​Mutable​Pointer<Int8>, max​Length:​ Int)

Invokes get​CString(_:​max​Length:​range:​remaining:​) with max​Length as the maximum length in char-sized units, the receiver’s entire extent as the range, and NULL for the remaining range.

Deprecated
func get​CString(Unsafe​Mutable​Pointer<Int8>, max​Length:​ Int, range:​ NSRange, remaining:​ NSRange​Pointer?)

Converts the receiver’s content to the default C-string encoding and stores them in a given buffer.

Deprecated
func adding​Percent​Escapes(using:​ UInt)

Returns a representation of the receiver using a given encoding to determine the percent escapes necessary to convert the receiver into a legal URL string.

Deprecated
func replacing​Percent​Escapes(using:​ UInt)

Returns a new string made by replacing in the receiver all percent escapes with the matching characters as determined by a given encoding.

Deprecated
func draw(with:​ NSRect, options:​ NSString​Drawing​Options = [], attributes:​ [String :​ Any]? = nil)

Draws the receiver with the specified options and other display characteristics of the given attributes, within the specified rectangle in the current graphics context.

Deprecated
func bounding​Rect(with:​ NSSize, options:​ NSString​Drawing​Options = [], attributes:​ [String :​ Any]? = nil)

Calculates and returns the bounding rect for the receiver drawn using the given options and display characteristics, within the specified rectangle in the current graphics context.

Deprecated

Constants

unichar

Type for UTF-16 code units.

NSString.Compare​Options

These values represent the options available to many of the string classes’ search and comparison methods.

NSString.Encoding​Conversion​Options

Options for converting string encodings.

NSString.Enumeration​Options

Constants to specify kinds of substrings and styles of enumeration.

NSString​Drawing​Options

The following constants are provided as rendering options for a string when it is drawn.

UIBaseline​Adjustment

Vertical adjustment options.

NSString Handling Exception Names

These constants define the names of exceptions raised if NSString cannot represent a string in a given encoding, or parse a string as a property list.

String Encoding Detection Options

The following constants are provided by NSString for use when detecting string encoding from a data object.