Access a char in a string, Swift 3.x

char, string, swift

Solution

Its pretty simple :

    let myText = Array("Hello World !!!".characters)
    print(myText[2]) // "l" will be printed

Problem

I can not find documentation on Apple's developer site. I have also been searching for the past few hours without a well-explained answer. I am trying to learn swift currently and I am trying to access a nth char in a string. In c++ I know you can do this with str[int value] ie. `string str = "This is a test string"; cout << str[2] << endl;` should print out "i" if I counted right. I am trying to do/find a way to do this in Swift and have not found an easy or way to do this. Is anyone able to help give some input?

Original source

Related problems