0

The method that I need to bind have argument in primitive array for example:

(bool)isRectangle:(const CGPoint[4])corners;

How I bind const CGPoint[4] type with C# type?

Note: Using Sharpie, the result is below

[Static]
[Export("isRectangle:")]
void IsRectangle(CGPoint[] corners);

and when I build it, I got error

cannot convert from 'CoreGraphics.CGPoint[]' to 'Foundation.NSObject'
Aromic
  • 73
  • 3
  • 8
  • CGPoint is struct defined in oc, refer to here https://developer.xamarin.com/guides/cross-platform/macios/binding/binding-types-reference/#BindAsAttribute maybe helpful. – ColeX Sep 15 '17 at 02:04

1 Answers1

0

Define the const CGPoint[4] as struct in your StructsAndEnums.cs:

[StructLayout(LayoutKind.Sequential)]
public struct Rectangle
{
    public CGPoint leftTop;
    public CGPoint rightTop;
    public CGPoint leftBotton;
    public CGPoint rightBotton;
}

Your definition becomes:

//(bool)isRectangle:(const CGPoint[4])corners;
[Export("isRectangle:")]
bool IsRectangle(Rectangle corners);
SushiHangover
  • 73,120
  • 10
  • 106
  • 165