Swift - 如何创建UnsafeMutablePointer <cgpoint>的NSArray?

时间:2016-05-07 08:55:10

标签: ios swift sprite-kit nsarray cgpoint

我尝试创建NSArray UnsafeMutablePointer<CGPoint>,以传递给SKSpriteNode splinePoints。这个问题非常类似于:Swift SKShapeNode shapeWithSplinePoints

我问它,因为那个帖子的答案似乎不起作用。根据其中一个答案,我需要:

  {p> NSArray其中CGPoint包含在NSValue个实例

虽然如何做到这一点?

我试过这个(这里建议How to create UnsafeMutablePointer<CGPoint> Object in swift

var shapePoints = [CGPoint]() // populate with points... let p = withUnsafeMutablePointer(&shapePoints) { $0 } let node = SKShapeNode(splinePoints: p, count: shapePoints.count)

此解决方案似乎很接近,但它适用于单个CGPoint,而不是CGPoint的数组,因此会抛出此错误:{{1} } UnsafeMutablePointer的百分比抑制率CGPoint] GT; Cannot convert value of type

提前致谢。

0 个答案:

没有答案