title: Xamarin binding byte[] or NSObject[]
body: <p>I am trying to bind the following function from an Objective-C library in Xamarin.</p>
  
  <pre><code>/*!
   *  This function writes data to the device.
   *
   *  @param writeBuffer Pointer to a byte buffer containing the write data.
   *  @param offset      Amount of data that was already written.
   *  @param size        Amount of data left to write.
   *
   *  @return Amount of data written.
   *
   *  @note Throws PortException on failure.
   */
  - (u_int32_t)writePort:(u_int8_t const *)writeBuffer :(u_int32_t)offSet :(u_int32_t)size;
  </code></pre>
  
  <p>I can't work out what the data type should be for writeBuffer. </p>
  
  <pre><code>    [Export ("writePort:::")]
      Int32 WritePort (Byte[] writeBuffer, int offSet, int size);
  </code></pre>
  
  <p>I have tried Byte[] (shown above) but I get the following error:</p>
  
  <pre><code>/Projects/StarIOBinding/StarIOBinding/obj/Debug/ios/StarIO/SMPort.g.cs(34,34): Error CS1502: The best overloaded method match for `MonoTouch.Foundation.NSArray.FromNSObjects(params MonoTouch.Foundation.NSObject[])' has some invalid arguments (CS1502) (StarIOBinding)
  </code></pre>
  
  <p>I then tried: </p>
  
  <pre><code>    [Export ("writePort:::")]
      Int32 WritePort (NSObject[] writeBuffer, int offSet, int size);
  </code></pre>
  
  <p>Which then compiles - but when running the command, I'm not getting the expected result. I am sending it a Byte[] wrapped up in an NSObject. Is NSObject the correct parameter and where am I going wrong?</p>
  
  <p><strong>Edit:</strong> When using IntPtr, I'm still getting no output. Can I just confirm I'm doing it correctly? My binding:</p>
  
  <pre><code>    [Export ("writePort:::")]
      Int32 WritePort (IntPtr writeBuffer, int offSet, int size);
  </code></pre>
  
  <p>And when I'm calling it:</p>
  
  <pre><code>    IntPtr test = System.Runtime.InteropServices.Marshal.AllocHGlobal(myByteArray.Length);
      System.Runtime.InteropServices.Marshal.Copy(myByteArray, 0, test, myByteArray.Length);
      SMPort devPort = SMPort.GetPort ("TCP:10.0.1.4", "", 5);
      int count = devPort.WritePort (test, 0, myByteArray.Length);
  </code></pre>