How to use NSPointArray?

Therefore, I want to use the method appendBezierPathWithPoints:count:in NSBezierPath. But the method requires me to use NSPointArray. The documentary doesn't really say that much, and all I can get is that it's an array of NSPoints, and I'm not sure how to do it. I think it uses a c-array mechanism, but I'm not sure.

Thank.

+5
source share
2 answers

Yes, you need an array of C points to go to appendBezierPathWithPoints:count:. For example, you can do something like this:

NSPoint pointArray[3];

pointArray[0] = NSMakePoint(0, 0);
pointArray[1] = NSMakePoint(0.5, 0.25);
pointArray[2] = NSMakePoint(1, 1);

[lines appendBezierPathWithPoints:pointArray count:3];

where linesis an instance NSBezierPath.

In a more complex case, you will use a variable number of points.

+8

Objective-C, NSValue.

NSMutableArray *array = [NSMutableArray array];

CGPoint myPoint;
myPoint.x = 100;
myPoint.y = 200;

[array addObject:[NSValue valueWithPoint:myPoint]];

NSPoint :

myPoint = [array[0] pointValue];

, .

+2

All Articles