我需要绑定(bind)的方法在原始数组中有参数,例如:
(bool)isRectangle:(const CGPoint[4])corners;
如何将 const CGPoint[4]
类型与 C# 类型绑定(bind)?
注意:使用Sharpie,结果如下
[Static]
[Export("isRectangle:")]
void IsRectangle(CGPoint[] corners);
当我构建它时,我收到错误
cannot convert from 'CoreGraphics.CGPoint[]' to 'Foundation.NSObject'
最佳答案
在 StructsAndEnums.cs
中将 const CGPoint[4]
定义为结构体:
[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);
关于objective-c - 如何使用 Objective Sharpie 绑定(bind) Objective-C 库中的 C 数组类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46210289/