Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 4
    In Swift 2 advance is no longer a global function but now a function on Index. s.startIndex.advanceBy(5) Commented Nov 9, 2015 at 13:04
  • 1
    Doesn't work for Swift 2.1. I got the msg: "value of type 'index'...has no member 'advancedBy'". Commented Nov 11, 2015 at 21:32
  • 2
    @FrederickC.Lee new syntax is s.startIndex.advancedBy(1) Commented Feb 8, 2016 at 20:22
  • 7
    Using NSString isn't really a Swift answer. Commented Sep 24, 2016 at 6:32
  • 1
    @benleggiero - did you read the answer? There are two methods given, one using Swift, one using NSString... Commented Apr 21, 2017 at 5:27