Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'advancedBy' is unavailable in Xcode 8 [closed]

Tags:

ios

swift

swift3

Currently, I've been using XCode 8 and on the line

let range = key.startIndex...key.startIndex.advancedBy(0)

I get the error:

error: 'advancedBy' is unavailable: To advance an index by n steps call 'index(_:offsetBy:)' on the CharacterView instance that produced the index.

How can I fix this?

A screenshot of the error is below:

advancedBy is unavailable

like image 575
Va Visal Avatar asked Jul 19 '16 04:07

Va Visal


1 Answers

advancedBy(_:) has been deprecated in Swift v3 and replaced by index(_:offsetBy:). Refer to Apple's migration guide for more info.

The solution to your error:

let range = key.startIndex...key.index(key.startIndex, offsetBy: 0)
like image 105
yohannes Avatar answered Nov 07 '22 17:11

yohannes