0

I'm trying to implement Spring iOS Animation Library, but quite a few errors were generated. Code in question:

let startIndex = hex.endIndex.advancedBy(1)

Additional Code:

if hex.hasPrefix("#") {
        let startIndex = hex.endIndex.advancedBy(1)
        _   = hex.substring(from: startIndex)
    }
Leo Dabus
  • 229,809
  • 59
  • 489
  • 571
  • Did you try `.advanced(by: 1)` – dan Sep 09 '16 at 19:41
  • 1
    Why are you trying to advance past the `endIndex`? In any case, the full error message tells you the solution – "*'advancedBy' is unavailable: To advance an index by n steps call 'index(_:offsetBy:)' on the CharacterView instance that produced the index.*" – Hamish Sep 09 '16 at 19:46
  • 1
    Thanks folks, the link by Leo helped me out. – Royalty Club Sep 09 '16 at 19:51
  • Assuming you're trying to remove the `#` from the string – you could also do `String(hex.characters.dropFirst())` – Hamish Sep 09 '16 at 19:58
  • http://stackoverflow.com/a/33459083/2303865 – Leo Dabus Sep 10 '16 at 01:38

0 Answers0