title: Extracting vertices from SceneKit iOS13 Swift 5
body: <p>Updating my code to <em>iOS 13</em> and <em>Swift 5</em>, I have this <strong>deprecated warning</strong>:</p>
  
  <blockquote>
    <p>'withUnsafeBytes' is deprecated: use <code>withUnsafeBytes&lt;R&gt;(_: (UnsafeRawBufferPointer) throws -&gt; R) rethrows -&gt; R</code> instead</p>
  </blockquote>
  
  <p>Over this fragment of code to extract the vertices from a SCNGeometry:</p>
  
  <pre><code>/// Extracts vertices from SCNGeometry
  func vertices() -&gt; [SCNVector3] {
      let vertexSources = self.sources(for: SCNGeometrySource.Semantic.vertex)
      if let vertexSource = vertexSources.first {
          let count = vertexSource.data.count / MemoryLayout&lt;SCNVector3&gt;.size
          return vertexSource.data.withUnsafeBytes {
               [SCNVector3](UnsafeBufferPointer&lt;SCNVector3&gt;(start: $0, count: count))
          }
      }
      return []
  }
  </code></pre>
  
  <p>The problem lays inside this lines:</p>
  
  <pre><code>return vertexSource.data.withUnsafeBytes {
      [SCNVector3](UnsafeBufferPointer&lt;SCNVector3&gt;(start: $0, count: count))
  }
  </code></pre>
  
  <p><a href="https://stackoverflow.com/a/44391570/8150874">This answer</a> gives solution here posted but there is no Swift 5 code, and I cannot come up with a solution for the warning.</p>
  
  <p><a href="https://stackoverflow.com/a/55378571/8150874">This other answer</a> and <a href="https://forums.swift.org/t/withunsafebytes-is-deprecated/24848" rel="nofollow noreferrer">this thread</a> seem to give a solution but for only a value of type <code>UInt32</code> not an <code>[SCNVector3]</code> <strong>(array)</strong>.</p>
  
  <p>Thank you all, I'm stuck.</p>