-2

I'm converting my Swift2.3 code to Swift3, and got an error at the line where I used advancedBy. XCode showing me a replacing code that using offsetBy, but I still don't understand.

func unhideEmaimage(_ imageFile: String) {
    let dotLocation = imageFile.characters.index(of: ".")

    self.emaImage.texture = SKTexture(imageNamed: imageFile)

    if dotLocation != nil {
        let filenameInitial = imageFile.startIndex
        let filenameLast = dotLocation!.advancedBy(-1)
        let filenamePart:String = imageFile[filenameInitial...filenameLast]
    }

And, following is the code that XCode showing me how to fix the error. However, I still don't know how to modify.

let filenameLast = "String.CharacterView corresponding to your index".index(dotLocation!, offsetBy: -1)

Please let me know the way to fix this error. Thank you in advance.

vanagar
  • 3,511
  • 2
  • 10
  • 8
  • 1
    Possible duplicate of [advancedBy is unavailable in Xcode 8](http://stackoverflow.com/questions/38449379/advancedby-is-unavailable-in-xcode-8) – vadian May 06 '17 at 04:51

1 Answers1

1

You should Write this:

let filenameLast = imageFile.index(dotLocation!,offsetBy: -1)
Pragnesh Vitthani
  • 2,532
  • 20
  • 28