To insert a character at a specific index in a string in Swift, you can use string manipulation methods like `insert(_:at:)`.
In this example,
str
with a value of "Hello World"
.insert(_:at:)
method to insert the character '!'
at index 5
.str
.var str = "Hello World"
let index = str.index(str.startIndex, offsetBy: 5)
str.insert("!", at: index)
print(str)
Hello! World
In this tutorial, we learned How to Insert Character at Specific Index in String in Swift language with well detailed examples.