[Swift]文字列分割

文字列分割

let datetimeString:String = "2016-02-17 14:51:21"
let tmp:[String] = datetimeString.componentsSeparatedByCharactersInSet(NSCharacterSet(charactersInString:"- :"))
print(tmp)

出力結果

["2016", "02", "17", "14", "51", "21"]