It seems like I cannot give the computed property a default value using the Initial Initializers method, which can be used for stored properties. Here, the case is used when I need it:
@IBDesignable public class MyRoundedCornersView: UIView { @IBInspectable var cornerRadius: CGFloat { get { return self.layer.cornerRadius } set { self.layer.cornerRadius = newValue } } }
I would like to give cornerRadius a default value. But the following does not work (just added = 8.0 ):
@IBDesignable public class MyRoundedCornersView: UIView { @IBInspectable var cornerRadius: CGFloat = 8.0 { get { return self.layer.cornerRadius } set { self.layer.cornerRadius = newValue } } }
I get a not very useful error '(() -> () -> $T1) -> $T2' is not identical to 'Double' . I looked here to find out how to do this, but Apple doesn't seem to support the default values ββfor computed properties. At least I could not find anything.
So, how can I make sure that I have a default value for my property? This thread says this is not possible in the init method, but even if I wanted to keep the default value next to my property definition. Does anyone have an idea?
source share