I would like to create a property wrapper which is invalidating the layout of my UICollectionViewLayout
.
Therefore I created this property wrapper
@propertyWrapper
class LayoutInvalidating {
private let layout: UICollectionViewLayout
init(layout: UICollectionViewLayout) {
self.layout = layout
self.wrappedValue = layout
}
var wrappedValue: UICollectionViewLayout {
didSet {
self.layout.invalidateLayout()
}
}
}
Then I would like to use it as follows
final class VehicleControlsCollectionViewLayout: UICollectionViewLayout {
@LayoutInvalidating(layout: self) // self is not alive
public var itemSize: CGSize = .init(width: 70, height: 70)
}
Everytime the property is set I would like to call self.invalidateLayout()
. Any ideas how I can access self when it's existing?