Create a Setter Only in Swift
Well if I really have to, I would use this.
Swift compiler supports some attributes on getters, so you can use @available(*, unavailable)
:
public subscript(index: Int) -> T { @available(*, unavailable) get { fatalError("You cannot read from this object.") } set(v) { }}
This will clearly deliver your intention to the code users.
From the docs:
The getter is used to read the value, and the setter is used to write the value. The setter clause is optional, and when only a getter is needed, you can omit both clauses and simply return the requested value directly, as described in Read-Only Computed Properties. But if you provide a setter clause, you must also provide a getter clause.
Use didSet
instead:
var masterFrame:CGRect { didSet { _imageView.frame = masterFrame _scrollView.frame = masterFrame }}