How to get CConstPointer in Swift?

1k Views Asked by At

I want to transform a CGPath with the transform CGAffineTransformMakeRotation(radians) but the CGPathCreateCopyByTransformingPath func takes a CConstPointer<CGAffineTransform>. How do I get a CConstPointer<CGAffineTransform> out of my CGAffineTransform?

1

There are 1 best solutions below

0
On BEST ANSWER

Pass the CGAffineTransform as an inout expression (that is, prefix it with &).

var xform = CGAffineTransformMakeRotation(3)
let newPath = CGPathCreateCopyByTransformingPath(originalPath, &xform)

Note that the transform must be a variable, not a Swift constant (declared with let).

c.f. Using Swift with Cocoa and Objective-C: Interacting with C APIs