A new function split in Swift 4

import Foundation
let sayHello = "Hello Swift ! 2019";
let result = sayHello.split(separator: " ")
print(result)

Output:

["Hello", "Swift", "!", "2019"]

Accessing values:

print(result[0]) // Hello
print(result[1]) // Swift
print(result[2]) // !
print(result[3]) // 2019

Xcode 8.1 / Swift 3.0.1

Here is the way multiple delimiters with array.

Keep the story going. Sign up for an extra free read.

You've completed your member preview for this month, but when you sign up for a free Medium account, you get one more story.
Already have an account? Sign in

Mr.Javed Multani

Written by

iOS Developer, Triple graduated, Passionate, Love workout, blogger

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade