Swift: Split a String into an array

In Objective-c we used componentsSeparatedByString

NSString *stringToSplit=@"str0,str1,str2,str3,str4,str5"; 
NSArray *arrayFromString = [str componentsSeparatedByString:@","];

In swift we can split a string into array simply by calling split() method

var stringToSplit = "str0,str1,str2,str3,str4,str5"

let arrayFromString = stringToSplit.split(separator: ",")

Less code.. 🙂

A pat on the back !!