Q:

Xamarin binding byte[] or NSObject[]

I am trying to bind the following function from an Objective-C library in Xamarin.
/*!
 *  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;

I can't work out what the data type should be for writeBuffer. 
    [Export ("writePort:::")]
    Int32 WritePort (Byte[] writeBuffer, int offSet, int size);

I have tried Byte[] (shown above) but I get the following error:
/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)

I then tried: 
    [Export ("writePort:::")]
    Int32 WritePort (NSObject[] writeBuffer, int offSet, int size);

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?
Edit: When using IntPtr, I'm still getting no output. Can I just confirm I'm doing it correctly? My binding:
    [Export ("writePort:::")]
    Int32 WritePort (IntPtr writeBuffer, int offSet, int size);

And when I'm calling it:
    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);

A:

You need to use IntPtr in the bindings and use the Marshal class to copy bytes back and forth.

