Search code examples
swift3cgpath

swift 3 CGPathAddCurveToPoint


I'm trying to update code to swift 3 but I can't find anything about CGPathAddCurveToPoint, how can I fix the error?

path is a CGMutablePath

CGPathAddCurveToPoint(path, nil, 10, 10, 20, 20, 30, 30)

error: nil is not compatible with expected argument type 'UnsafePoiter'

I found that CGPathAddLineToPoint(path, nil, 10, 10) became path.addLine(to: p0)


Solution

  • Please read the CGMutablePath docs:

    https://developer.apple.com/reference/coregraphics/cgmutablepath

    You will find:

    func addCurve(to end: CGPoint, control1: CGPoint, control2: CGPoint, 
        transform: CGAffineTransform = default)
    

    Note that this is now a method, not a loose global function.