Created
December 24, 2014 09:33
-
-
Save yannxou/73fba6a4df515462a041 to your computer and use it in GitHub Desktop.
Swift: Computed lazy variable example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private lazy var debugLabel: UILabel = { | |
let label = UILabel(frame: CGRectMake(20, 20, 200, 20)) | |
label.textColor = UIColor.redColor() | |
label.backgroundColor = UIColor.whiteColor() | |
return label | |
}() // the parentheses tells swift to use the return value of the closure, not the closure itself. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment