@@ -9,8 +9,10 @@ import UIKit
99
1010class TableViewCell : UITableViewCell
1111{
12- let kLabelHorizontalInsets = 15.0
13- let kLabelVerticalInsets = 10.0
12+ // The CGFloat type annotation is necessary for these constants because they are passed as arguments to bridged Objective-C methods,
13+ // and without making the type explicit these will be inferred to be type Double which is not compatible.
14+ let kLabelHorizontalInsets : CGFloat = 15.0
15+ let kLabelVerticalInsets : CGFloat = 10.0
1416
1517 var didSetupConstraints = false
1618
@@ -64,19 +66,16 @@ class TableViewCell: UITableViewCell
6466 self . bodyLabel. autoSetContentCompressionResistancePriorityForAxis ( . Vertical)
6567 }
6668
67- // FIXME 7-Jun-14 Xcode 6b1: The Double literals below should refer to the defined constants kLabelHorizontalInsets and kLabelVerticalInsets.
68- // However, there are currently intermittent compiler failures when the literals are replaced with these constants. For example, 'Could not find member .Top'
69-
70- titleLabel. autoPinEdgeToSuperviewEdge ( . Top, withInset: 10.0 )
71- titleLabel. autoPinEdgeToSuperviewEdge ( . Leading, withInset: 15.0 )
72- titleLabel. autoPinEdgeToSuperviewEdge ( . Trailing, withInset: 15.0 )
69+ titleLabel. autoPinEdgeToSuperviewEdge ( . Top, withInset: kLabelVerticalInsets)
70+ titleLabel. autoPinEdgeToSuperviewEdge ( . Leading, withInset: kLabelHorizontalInsets)
71+ titleLabel. autoPinEdgeToSuperviewEdge ( . Trailing, withInset: kLabelHorizontalInsets)
7372
7473 // This constraint is an inequality so that if the cell is slightly taller than actually required, extra space will go here
7574 bodyLabel. autoPinEdge ( . Top, toEdge: . Bottom, ofView: titleLabel, withOffset: 10.0 , relation: . GreaterThanOrEqual)
7675
77- bodyLabel. autoPinEdgeToSuperviewEdge ( . Leading, withInset: 15.0 )
78- bodyLabel. autoPinEdgeToSuperviewEdge ( . Trailing, withInset: 15.0 )
79- bodyLabel. autoPinEdgeToSuperviewEdge ( . Bottom, withInset: 10.0 )
76+ bodyLabel. autoPinEdgeToSuperviewEdge ( . Leading, withInset: kLabelHorizontalInsets )
77+ bodyLabel. autoPinEdgeToSuperviewEdge ( . Trailing, withInset: kLabelHorizontalInsets )
78+ bodyLabel. autoPinEdgeToSuperviewEdge ( . Bottom, withInset: kLabelVerticalInsets )
8079
8180 didSetupConstraints = true
8281 }
0 commit comments