0
votes

hey guys i've been trying to create a path but it always end up showing an error ''cannot convert value of type NSNull to expected argument UnsafePointer< CGAffineTransform > '' i dont know how to get the UnsafePointer< CGAffineTransform > to be nil

here is the code

class func path(radius: Double) -> CGMutablePath {
    var path: CGMutablePath = CGMutablePath()
    CGPathAddArc(path, NSNull ,  0.0, 0.0, radius, 0.0, 2.0 * M_PI, true)
    return path

  }
2

2 Answers

1
votes

In Swift 3 the signature of the add arc function is wrong anyway:

class func path(radius: CGFloat) -> CGMutablePath {
    let path = CGMutablePath()
    path.addArc(center: CGPoint(), radius: radius, startAngle: 0.0, endAngle: 2.0 * .pi, clockwise: true)
    return path
 }

The transform parameter is optional which is nil by default.

0
votes

The CGPathAddArc function is, in Swift 3.0 and later, a method on CGMutablePath:

class func path(radius: Double) -> CGMutablePath {
    var path: CGMutablePath = CGMutablePath()
    path.addArc(center: .zero, radius: CGFloat(radius), startAngle: 0, endAngle: 2 * .pi,
        clockwise: true)
    return path
}

The transform argument is optional and defaults to nil, so you can omit it entirely, as I have done.