setter must be with getter swift
// Sure. You can just return a nil and make the type optional:
var color: MyColorEnum? {
get { return nil }
set {
switch newValue! {
case .Blue:
view.backgroundColor = UIColor.blueColor()
case .Red:
view.backgroundColor = UIColor.redColor()
}
}
}
// Alternatively, you may use didSet to avoid the issue all together:
var color: MyColorEnum! {
didSet {
switch color {
case .Blue:
view.backgroundColor = UIColor.blueColor()
case .Red:
view.backgroundColor = UIColor.redColor()
}
}
}
Also in Swift:
- swift remove tableview cell
- if statement swfit
- playing a sound in swift
- swift reload tableview
- remove back button from navigation bar swift
- get device name swift
- swift add navigation bar
- ui alert swift yes no
- swift uicollectionviewcell how to know when off screen
- convert meter to miles swift
- conert data to string swift
- swift parse json
- swift retrieve value from dictionary
- markdown
- swift add image to button
- how to dismiss keyboard swiftui
- swift get day from available string
- change textfield placeholder color swiftui
- declare function in swift
- swift navigation bar title font
- save date to userdefaults swift
- swift create label programmatically
- remove child from firebase swift
- uiimage swift src url