-1
func setupCircular(circularLayer:inout CAShapeLayer?){
    if (circularLayer == nil) {
        circularLayer = CAShapeLayer()
    }else{

    }
}
setupCircular(circularLayer: &nil)

how to write?

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
loseDream
  • 87
  • 1
  • 13

1 Answers1

2

You cannot use a value as an inout parameter in Swift. You need to create a variable of type CAShapeLayer, assing it a nil value and use that as the input parameter to your function.

func setupCircular(circularLayer:inout CAShapeLayer?){
    if (circularLayer == nil) {
        circularLayer = CAShapeLayer()
    }else{

    }
}

var circ: CAShapeLayer? = nil
setupCircular(circularLayer: &circ)
Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116