I have MyLayer
and it has a sublayer that it also holds a reference to. In that setup what is the proper way to override init(layer: Any)
?
Right now I'm doing it like this ... layer.mySublayer.presentation()!
is that correct? Is that always going to work, or will presentation ever be nil in this context?
Thanks for any tips!
class MyLayer: CALayer {
var mySublayer: CALayer
public override init() {
mySublayer = CALayer()
super.init()
addSublayer(mySublayer)
}
override init(layer: Any) {
let layer = layer as! MyLayer
mySublayer = layer.mySublayer.presentation()!
super.init(layer: layer)
}
required init?(coder: NSCoder) {
fatalError("has not been implemented")
}
}