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 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.