How to binding C array type in objective-c library using Objective Sharpie?

159 views Asked by At

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'
1

There are 1 answers

0
SushiHangover On

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);