lazy + private(set)

Here’s the code if you want to experiment with it:

import UIKit

class ViewController: UIViewController {

    private(set) lazy var subview: UIView = {
        let view = UIView()
        // configure `view`
        return view
    }()

    /* ... */
}
Previous
Previous

better compactMap

Next
Next

guard statements