If I define a UICollectionViewCell subclass:
class TestCell<T>: UICollectionViewCell {
var float: CGFloat? = 3
var string = "abc"
}
Register it:
collectionView.registerClass(TestCell<String>.self, forCellWithReuseIdentifier: "Test")
Then use it:
collectionView.dequeueReusableCellWithReuseIdentifier("Test", forIndexPath: indexPath) as! TestCell<String>
I notice strange behavior with the properties that should have been initialized.
- float == Optional(0.0)
- string == ""
Why is this happening and how can I fix it?
This is on Xcode 7.3