Instance Method

components(separatedBy:)

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

Declaration

func components(separatedBy separator: CharacterSet) -> [String]

Parameters

separator

A character set containing the characters to to use to split the receiver. Must not be nil.

Return Value

An NSArray object containing substrings from the receiver that have been divided by characters in separator.

Discussion

The substrings in the array appear in the order they did in the receiver. Adjacent occurrences of the separator characters produce empty strings in the result. Similarly, if the string begins or ends with separator characters, the first or last substring, respectively, is empty.

See Also

Related Symbols

func components(separatedBy: String)

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

func trimmingCharacters(in: CharacterSet)

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