Here's a couple of functions that make it more objective-c like
func substringOfString(_ s: String, toIndex anIndex: Int) -> String
{
return s.substring(to: s.index(s.startIndex, offsetBy: anIndex))
}
func substringOfString(_ s: String, fromIndex anIndex: Int) -> String
{
return s.substring(from: s.index(s.startIndex, offsetBy: anIndex))
}
//examples
let str = "Swift's String implementation is completely and utterly irritating"
let newstr = substringOfString(str, fromIndex: 30) // is completely and utterly irritating
let anotherStr = substringOfString(str, toIndex: 14) // Swift's String
let thisString = substringOfString(anotherStr, toIndex: 5) // Swift