The default value of the method parameter is evaluated in the class area, not the instance area, as can be seen in the following example:
class MyClass { static var foo = "static foo" var foo = "instance foo" func calcSomething(x: String = foo) { print("x =", x) } } let obj = MyClass() obj.calcSomething()
and it wonβt compile without static var foo .
For your case, this means that you must use the property, which is used as the default value of static:
class supClass: UIView { static let defaultFontSize: CGFloat = 12.0
(Note that for this problem it does not matter if the property is defined in the same class or superclass.)
source share