I am trying to provide a default value for a variable in a Protocol. I am getting an error:
Type ViewController does not conform to protocol Test
Code:
protocol Test {
var aValue: CGFloat { get set }
}
extension Test {
var aValue: CGFloat {
return 0.3
}
}
class ViewController: UIViewController, Test {
override func viewDidLoad() {
super.viewDidLoad()
print("value \(aValue)")
}
}
How can I provide a default value so the ViewController
can use the default value (in the protocol extension) without to declaring it?