How to use NSPointArray?

非 Y 不嫁゛ 提交于 2019-12-05 10:51:16

Yes, you need a C-style array of points to pass to appendBezierPathWithPoints:count:. For example you might 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 lines is an instance of NSBezierPath.

In a more complicated case you'll use a variable number of points say.

sumit.kumar

If you want to use Objective-C style array, then you have to use NSValue class for this purpose.

NSMutableArray *array = [NSMutableArray array];

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

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

To retrieve an NSPoint back from the array:

myPoint = [array[0] pointValue];

Hope it helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!