Skip to main content
4 of 7
added 18 characters in body
phnmnn
  • 13.3k
  • 11
  • 50
  • 69

SWIFT 2.0/3.0 in Xcode 8 beta 5

simple:

let myString = "full text container" myString[myString.startIndex..<myString.startIndex.advancedBy(3)] // prints: ful 

swift 3.0 in Xcode 8 beta 6 or later

myString[myString.startIndex..<myString.index(myString.startIndex, offsetBy: 3)] // prints: ful 
phnmnn
  • 13.3k
  • 11
  • 50
  • 69