Swift - Data Type String Splitting

Introduction

You can split a string

Demo

var fruitsStr = "apple,orange,pineapple,durian"
var fruits = fruitsStr.componentsSeparatedByString(",")
for fruit in fruits {
    print(fruit)/*from  w w  w .  j  av  a 2s.  c  om*/
}

Here, the code extracts the string to an array of items separated by the comma ','.

Related Topic