Inserts a collection of characters at the specified position.
SDK
- Xcode 7.1+
Framework
- Swift Standard Library
Declaration
mutating func insert<S>(contentsOf newElements: S, at i: String.Index) where S : Collection, S.Element == Character
Parameters
newElementsA collection of
Characterelements to insert into the string.iA valid index of the string. If
iis equal to the string’s end index, this methods appends the contents ofnewto the string.Elements
Discussion
Calling this method invalidates any existing indices for use with this string.
Complexity: O(n), where n is the combined length of the string and new.