JuJoDi
JuJoDi

Reputation: 14975

How to get CConstPointer in Swift?

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?

Upvotes: 2

Views: 1004

Answers (1)

user1720115
user1720115

Reputation:

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

Upvotes: 8

Related Questions