I\'m not sure how to resolve the above error messages, I have tried to convert it to index b
In Swift 3, advancedBy()
has been renamed to advanced(by: Int)
.
Additionally, substringWithRange
has been renamed to substring(with: Range)
.
The error (sometimes more easily seen in the "Issues Navigator", by pressing option+4) says:
error: 'advancedBy' is unavailable: To advance an index by n steps call 'index(_:offsetBy:)' on the CharacterView instance that produced the index.
Thus you could do:
let r = testStr.index(testStr.startIndex, offsetBy: range.location) ..< testStr.index(testStr.startIndex, offsetBy: range.location + range.length)
let result = testStr[r]
Or
let start = testStr.index(testStr.startIndex, offsetBy: range.location)
let end = testStr.index(start, offsetBy: range.length)
let result = testStr[start ..< end]