0

I'm not understanding how to extract a string in Swift 3, now I have this warning:

'init(start:end:)' is deprecated: it will be removed in Swift 3. Use the '..<' operator.

The code where this warning appear is the following:

labelReps.text = reps.substringWithRange(Range<String.Index>(start: reps.startIndex, end: reps.endIndex.advancedBy(-4)))

How can I translate that code in the new Swift 3 way?

Sulthan
  • 128,090
  • 22
  • 218
  • 270
Luca Alberto
  • 1,195
  • 3
  • 11
  • 30
  • 1
    `reps.substringWithRange(reps.startIndex ..< reps.endIndex.advancedBy(-4))` – dan Apr 07 '16 at 19:47
  • Here is an extension that works like a charm in Swift 3: http://stackoverflow.com/questions/24044851/how-do-you-use-string-substringwithrange-or-how-do-ranges-work-in-swift/39742687#39742687 – winterized Sep 28 '16 at 09:14

0 Answers0