Skip to content

Instantly share code, notes, and snippets.

@phynet
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phynet/5b0a2af572c404a0123d to your computer and use it in GitHub Desktop.
Save phynet/5b0a2af572c404a0123d to your computer and use it in GitHub Desktop.

Previous Swift 2.0, the option .character for String's type, was obtained using advance and startIndex (pretty much a pain in the butt, so make it an extension and you could have the characters :P )

var kString = "My string"
var countString = count(kString)

for i in 0...countString - 1 {
  let index = advance(kString.startIndex, i)
  print("INSIDE FOR \(kString[index])")
  self.labelAmount.text?.append(kString[index])
  
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment