Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

split a string to an array (each character) - Swift [duplicate]

I've got a little problem. I want to split a String in an array of characters, where I can work on each character.

For example:

"Hello"
    arrayofstring[0] ->H
    arrayofstring[1] ->e
    arrayofstring[2] ->l
    arrayofstring[3] ->l
    arrayofstring[4] ->o

I am thankful for every help.

like image 384
MisterMushn Avatar asked Jan 06 '23 08:01

MisterMushn


1 Answers

Unless I'm missing something, it's easier than either of the other answers:

let arrayofstring = Array("Hello".characters)
like image 52
Aaron Rasmussen Avatar answered Feb 08 '23 16:02

Aaron Rasmussen