title: How to use CPointer in Kotlin/Native
body: <p>I cannot find out how to use CPointer in Kotlin/Native; In my iOS source set, I need to build the Kotlin equivalent of the following Object-c code (only including relevant parts of the code):</p>
  <pre><code>    //Object-C copyItemAtPath
      NSError* error=nil;
      [[NSFileManager defaultManager]copyItemAtPath:srcPath toPath:dstPath error:&amp;error ];
      if (error!=nil) {
          NSLog(@&quot;%@&quot;, error);
      }
  </code></pre>
  <p>But in Kotlin/Native,I dont know how to transfrom the code;I tried the following kotlin code and failed;</p>
  <pre><code>        //I try to read error info 
          val errorPtr = allocPointerTo&lt;ObjCObjectVar&lt;NSError?&gt;&gt;()
          NSFileManager.defaultManager.copyItemAtPath(&quot;source&quot;, target,errorPtr.value)
          Napier.e(&quot;[KNDraftCopy]${errorPtr.pointed?.value?.localizedDescription}&quot;)//null
          Napier.e(&quot;[KNDraftCopy]${errorPtr.pointed?.value}&quot;)//null
          Napier.e(&quot;[KNDraftCopy]${errorPtr.pointed}&quot;)//null
          Napier.e(&quot;[KNDraftCopy]${errorPtr}&quot;)//kotlinx.cinterop.NativePointed@d063d3a8
  </code></pre>
  <p>I am a fish of C Code,there is the question of me:
  How to transform my Obj-C code to kotlin/native?
  Is my way right?(The result is invalid.)</p>
  <pre><code>// the function definition
  fun copyItemAtPath(srcPath: kotlin.String, toPath: kotlin.String, error:CPointer&lt;ObjCObjectVar&lt;platform.Foundation.NSError?&gt;&gt;?)
  </code></pre>