I'm trying to draw a bezier curve in cocoa and I'm getting a EXC_BAD_INSTRUCTION that doesn't seem to make any sense at all.
here's my code:
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];
My application crashes when the following line is executed:
[path addCurveToPoint: b controlPoin1:c1 controlPoint2:c2];
And Xcode tells me it crashes in my main loop:
[NSApp runModalSession:modalSession];
The error output is the following:
2016-12-08 04:38:35.344601 unit_tests[10606:777278] -[NSBezierPath addCurveToPoint:controlPoint1:controlPoint2:]: unrecognized selector sent to instance 0x100428fa0
(lldb)
You have a typo with controlPoin1: c1
It should be controlPoint1: c1
Actually I've just realised you're targeting AppKit (NSBezierPath) not UIKit (UIBezierPath).
Edit:
For AppKit use: -[NSBezierPath curveToPoint: controlPoint1: controlPoint2:]
For UIKit use -[UIBezierPath addCurveToPoint: controlPoint1: controlPoint2:]