[Solved] How to change or update string of array with Swift


Here is a possible way:

var letters: [Character] = ["a", "b", "c", "d"]

let insertionIndex = newArray[0]
    .index(newArray[0].startIndex, offsetBy: 5)

for index in newArray.indices {
    newArray[index].insert(letters[index], at: insertionIndex)
}

And you could check the result this way:

newArray.forEach { print($0) }

Which prints:

self.aButton.setTitle("?", for: .normal)
self.bButton.setTitle("?", for: .normal)
self.cButton.setTitle("?", for: .normal)
self.dButton.setTitle("?", for: .normal)

0

solved How to change or update string of array with Swift