0

我需要绑定的方法在原始数组中有参数,例如:

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

如何将const CGPoint[4]类型与 C# 类型绑定?

注意:使用 Sharpie,结果如下

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

当我构建它时,我得到了错误

cannot convert from 'CoreGraphics.CGPoint[]' to 'Foundation.NSObject'
4

1 回答 1

0

在您的中定义const CGPoint[4]as 结构StructsAndEnums.cs

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

你的定义变成:

//(bool)isRectangle:(const CGPoint[4])corners;
[Export("isRectangle:")]
bool IsRectangle(Rectangle corners);
于 2017-09-14T06:30:07.457 回答