How do I get the string before a certain character in swift? The code below is how I did it in Objective C, but can\'t seem to perform the same task in Swift. Any tips or su
You can use rangeOfString, but it returns a Range type, not a NSRange:
rangeOfString
Range
NSRange
let string = "hello Swift" if let range = string.rangeOfString("Swift") { print(string.substringToIndex(range.startIndex)) }