Getting character from a string in Swift
Forums:
let str = "ABC"
let charArray = Array(str.characters)
let charA = charArray[0]
//charA is "A"
let charB = charArray[1]
//charB is "B"
let charC = charArray[2]
//charC is "C"
var charList = ""
for c in str.characters {
charList += String(c) + ";"
}
//charList is "A;B;C;"
- Log in to post comments