How to count how many characters a string has - Swift

Asked

Viewed 692 times

3

I’m having some difficulties with simple things. How do I count how many letras has a variable?

let word = wordEasy[0]
for var i = 0; i < word.count ?????

1 answer

5

If it is Swift 1:

word.utf16count

If it is Swift 2:

word.characters.count
  • Thank you very much!

  • Bruno, if the answer satisfies your question, select it as the accepted answer, to help other people who may have the same question in the future

Browser other questions tagged

You are not signed in. Login or sign up in order to post.