addCurveToPoint crashing with EXC_BAD_INSTRUCTION



我正在尝试在可可中绘制一个比较曲线的曲线,而我得到的exc_bad_instruction似乎根本没有任何意义。

这是我的代码:

NSBezierPath *path = [NSBezierPath bezierPath];
[path setLineWidth: 1.0f];
NSPoint a = NSMakePoint(0, 0);
NSPoint c1 = NSMakePoint(0, 50);
NSPoint c2 = NSMakePoint(50, 100);
NSPoint b = NSMakePoint(100, 100);
[path moveToPoint:a];
[path addCurveToPoint: b controlPoint1:c1 controlPoint2:c2];
[[NSColor colorWithDeviceRed:1 green:0 blue:0 alpha:1] set];
[path stroke];

执行以下行时我的应用程序崩溃:

[path addCurveToPoint: b controlPoin1:c1 controlPoint2:c2];

和Xcode告诉我它在我的主循环中崩溃:

[NSApp runModalSession:modalSession];

错误输出如下:

2016-12-08 04:38:35.344601 unit_tests[10606:777278] -[NSBezierPath addCurveToPoint:controlPoint1:controlPoint2:]: unrecognized selector sent to instance 0x100428fa0

(lldb)

您有一个带有 controlPoin1: c1的错别字,应该是 controlPoint1: c1

实际上我刚刚意识到您是针对AppKit(NSBezierPath)而不是Uikit(Uibezierpath)。

编辑:

用于AppKit使用:-[NSBezierPath curveToPoint: controlPoint1: controlPoint2:]

用于UIKIT使用-[UIBezierPath addCurveToPoint: controlPoint1: controlPoint2:]

相关内容

  • 没有找到相关文章

最新更新