A
A
Aleksandr Govorukhin2016-02-22 21:45:53
iOS
Aleksandr Govorukhin, 2016-02-22 21:45:53

How to access the index of a row? Swift 2?

Hello! How to access an element of a string? For example:

let text = "four score and seven years ago"
for var index = text.characters.count - 1; index != 0; index-- {
   print(text.characters[index])
}

Tell me how to do it right?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Aleksandr Govorukhin, 2016-02-22
@SnapSh0t

let text2 = "four score and seven years ago"

for var index = text2.characters.count - 1; index != 0; index-- {
   var index2 = text2.startIndex.advancedBy(index)
    print(text2[index2])
}

A
An, 2016-02-22
@Flanker_4

stackoverflow.com/questions/24092884/get-nth-chara...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question