title: Converting UTF16View.Index advanced by function in Swift 4
body: <p>So in Swift 3, I had this function to convert a String representing Hexa data to Data type:</p>
  
  <pre class="lang-swift prettyprint-override"><code>extension String {
  
  public func fromHexStringtoData() -&gt; Data? {
      func convertToUInt8(u: UInt16) -&gt; UInt8? {
          switch(u) {
          case 0x30 ... 0x39:
              return UInt8(u - 0x30)
          case 0x41 ... 0x46:
              return UInt8(u - 0x41 + 10)
          case 0x61 ... 0x66:
              return UInt8(u - 0x61 + 10)
          default:
              return nil
          }
      }
  
      let utf16 = self.utf16
      guard let data = NSMutableData(capacity: utf16.count/2) else { return nil }
      var i = utf16.startIndex
      while i != utf16.endIndex {
          guard let hi = convertToUInt8(u: utf16[i]) else { return nil }
  
          //Need to convert following line to Swift 4
          guard let lo = convertToUInt8(u: utf16[i.advanced(by: 1)]) else { return nil }
  
          var value = hi &lt;&lt; 4 + lo
          data.append(&amp;value, length: 1)
  
          //Need to convert following line to Swift 4
          i = i.advanced(by: 2)
      }
      return data as Data
  }
  
  }
  </code></pre>
  
  <p>How can I convert the <code>advanced(by: n)</code> in an optimal way?</p>