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.
To achieve good performance and no loss of time between data transfer obj-C<->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:
private IntPtr WrapIntArray(int[] array) {
IntPtr intPtr;
unsafe
{
fixed (int* pArray = array)
{
intPtr = new IntPtr((void *) pArray);
}
}
return intPtr;
}
This IntPtr is then used to be passed to the exported bound method:
[Export("....")]
void method(IntPtr input, IntPtr output);
My library works well in armv7 devices if run on monotouch 32 bits.
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).
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.
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?
Thanks
Antonio