var password : string = "F36fjueEA5lo903"
i need separte this character by character.
something like this.
var 1character : string = "F"
var 2character : string = "3"
var 3character : string = "6"
. . .
PD: I am a novice
var password : string = "F36fjueEA5lo903"
i need separte this character by character.
something like this.
var 1character : string = "F"
var 2character : string = "3"
var 3character : string = "6"
. . .
PD: I am a novice
You can do it with:
let characters = Array(password)
With this you have an array of the characters in the String. You can assign it to other variables if you want to.
While you can do it like Jacobson showed you in his answer(perfectly fine), you shouldn't save the letters manually in own variables. Because you often don't know the length of the password. So what you could do is iterating over your chars:
for letter in yourString{
//do something with the current letter
var yourCurrentLetter = letter
println(yourCurrentLetter)//a then s, d, f etc.
}