Swift - Converting Strings to Arrays

Introduction

You can convert a String value into an array.

The following statement shows str containing a string with a Unicode character:

var str = "voila" + "\u{300}" // voila + `

You can convert the string into an Array instance:

var arr = Array (str)

Once the string is converted to an array, you can access its individual characters through its index:

print(arr[4])  

Demo

var str = "voila" + "\u{300}" // voila + `
var arr = Array (str)
print(arr[4])

Result

Related Topic