If I have a class property
let appDelegate: AppDelegate? = UIApplication.shared.delegate as? AppDelegate
Each time appDelegate is accessed, would it return the value at the time it is accessed, or would it return the value the first time it was accessed?
I'm trying to understand whether the property above works the same way as
let appDelegate: AppDelegate? = {
return UIApplication.shared.delegate as? AppDelegate
}()
The second declaration of the appDelegate property runs the closure the first time the property is accessed and never again. Later references to appDelegate returns the value that was returned the first time the property was accessed.