Created
March 9, 2017 13:27
-
-
Save mamnun/9aab28db245cf4b9dd568fe01021f716 to your computer and use it in GitHub Desktop.
Reference types in swift structs
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
struct AdConfig { | |
var prefetchCount:Int | |
var wrapperView:UIView? | |
static let `default`: AdConfig = AdConfig(prefetchCount: 10, wrapperView: UIView(frame:CGRect.zero)) | |
} | |
print(AdConfig.default.wrapperView?.backgroundColor) // prints nil | |
var customConfig = AdConfig.default | |
customConfig.wrapperView?.backgroundColor = UIColor.red | |
print(AdConfig.default.wrapperView?.backgroundColor) // prints red |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment