Hi,
my way to split one array (of String) in two or more var
sometimes you have a Date() in a String format, and you want only the year.
you can use .components(separatedBy: "/")
func splitArray() {
let myARRAY = "20/09/2021"
let SplittedArray = myARRAY.components(separatedBy: "/")
let DAY = SplittedArray[0]
let MONTH = SplittedArray[1]
let YEAR = SplittedArray[2]
print("\(DAY), \(MONTH), \(YEAR)")
}
Top comments (0)