Instance Property


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


var length: Int { get }


This number includes the individual characters of composed character sequences, so you cannot use this property to determine if a string will be visible when printed or how long it will appear.

See Also

Getting a String’s Length

func lengthOfBytes(using: UInt) -> Int

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

func maximumLengthOfBytes(using: UInt) -> Int

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

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software