title: Xamarin Unified API - How to handle array binding using IntPtr?
body: <p>I've been using my bindings and static Accelerate Obj C library for a long time in Xamarin.iOS. Due to the unified API and the 64 bit arch in newer iOS devices i was forced to successfully update and compile my new version of library and link it with appropriate bindings.</p>
  
  <p>To achieve good performance and no loss of time between data transfer obj-C&lt;->C# due to working with big chunks of data (big image arrays) i decided to bind arrays from c# to obj-c using unsafe code and generally wrapping the array using an IntPtr, i.e:</p>
  
  <pre><code>private IntPtr WrapIntArray(int[] array) {
      IntPtr intPtr;
      unsafe
      {
          fixed (int* pArray = array)
          {
              intPtr = new IntPtr((void *) pArray);
          }
      }
      return intPtr;
  }
  </code></pre>
  
  <p>This IntPtr is then used to be passed to the exported bound method:</p>
  
  <pre><code>[Export("....")]
  void method(IntPtr input, IntPtr output);
  </code></pre>
  
  <p>My library works well in armv7 devices if run on monotouch 32 bits.</p>
  
  <p>When i decided today to run in a build configuration of armv7+arm64 my library stopped working and i have a crash. After investigating and debugging i found that now when i declare my IntPtr wrapper for array in C# its size 8 bytes (64 bits).</p>
  
  <p>Because i use the obj-c library to set the "output" of the method by assigning values of 32 bits to the array (i.e. output[43] = 2) causes the crash.</p>
  
  <p>Can someone please help me understand how can i cope with this new case the way i do bindings and without changing my obj-c library?</p>
  
  <p>Thanks</p>
  
  <p>Antonio</p>