I uses storyboard to build the layout. I am trying to access func in firstViewController
from secondViewController
but when I use the following code to access it I will always get "Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value" no matter what function or outlet I have tried to access I always get the same error. Did I miss anything or am I doing it wrongly?
done
is located in secondViewController
func done(){
let vc = firstViewController()
vc.drawCircle(locationX: 0, locationY: 0)
}
drawCircle
is located in firstViewController
func drawCircle(locationX:CGFloat, locationY: CGFloat) {
let path = UIBezierPath(roundedRect: CGRect(x: locationX, y: locationY, width: radius, height: radius), cornerRadius: 50).cgPath
combinePath.addPath(path)
layer.path = combinePath
if thickness>0{
layer.strokeColor = UIColor(red: rColor, green: gColor, blue: bColor, alpha: 1).cgColor
layer.fillColor = UIColor.clear.cgColor
layer.lineWidth = thickness
}
imageView.layer.addSublayer(layer)
}