Skip to content

Commit 514c561

Browse files
committed
Don't set mode initial value in init because it won't call mode's property observer.
1 parent 5bc9d30 commit 514c561

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

WooCommerce/Classes/ViewRelated/ReusableViews/TwoColumnLabelView.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class TwoColumnLabelView: UIView {
99
case title
1010
}
1111

12-
var mode: Mode {
12+
var mode: Mode = .body{
1313
didSet {
1414
refreshStyle(mode: mode)
1515
}
@@ -45,14 +45,17 @@ class TwoColumnLabelView: UIView {
4545
}
4646

4747
required init?(coder aDecoder: NSCoder) {
48-
mode = .body
48+
// initializers don't call property observers,
49+
// so don't set the default for mode here.
4950
super.init(coder: aDecoder)
5051
}
5152

52-
class func makeFromNib() -> TwoColumnLabelView {
53-
return Bundle.main.loadNibNamed("TwoColumnLabelView", owner: self, options: nil)?.first as! TwoColumnLabelView
53+
override func awakeFromNib() {
54+
super.awakeFromNib()
55+
mode = .body // trigger the property observer
5456
}
55-
}
5657

58+
class func makeFromNib() -> TwoColumnLabelView {
59+
return Bundle.main.loadNibNamed("TwoColumnLabelView", owner: self, options: nil)?.first as! TwoColumnLabelView
5760
}
5861
}

0 commit comments

Comments
 (0)