One question came into my mind today while working with objective c again after long time. Lets say I have following code for computed initializer that is written in swift 3.0.
private let loginButton: UIButton = {
let button = UIButton(type: .system)
button.backgroundColor = UIColor(hex: 0x0083C5, alpha: 1)
button.setTitle("Login", for: .normal)
button.setTitleColor(UIColor.white, for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 20, weight: .bold)
button.layer.cornerRadius = 5
return button
}()
Above code returns an instance of UIButton. How can I write same code in objective C?
Update: I already know the way of using Lazy Instantiation. Is there any other way from which I can create immutable instances?