Skip to main content
2 of 4
added 285 characters in body
Warif Akhand Rishi
  • 24.3k
  • 8
  • 82
  • 109

##Swift 2.0 Simple

let str = "My String" let subStr = str[str.startIndex.advancedBy(3)...str.startIndex.advancedBy(7)] //"Strin" 

##Swift 3

let startIndex = str.index(str.startIndex, offsetBy: 3) let endIndex = str.index(str.startIndex, offsetBy: 7) str[startIndex...endIndex] // "Strin" str.substring(to: startIndex) // "My " str.substring(from: startIndex) // "String" 
Warif Akhand Rishi
  • 24.3k
  • 8
  • 82
  • 109