Hey
I was just wondering why I am getting this error when I'm doing what the "Intro to App Development with Swift" book. My error is on lesson 17.3 and here is my code: (just wondering what I'm doing wrong, I'm new to Swift!!)
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
updateColor()
/
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
/
}
@IBOutlet weak var colorView: UIView!
@IBAction func redSwitch(_ sender: UISwitch) {
}
@IBAction func greenSwitch(_ sender: UISwitch) {
}
@IBAction func blueSwitch(_ sender: UISwitch) {
}
func updateColor() {
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
if redSwitch.isOn { error here
red = 1
}
if greenSwitch.isOn { error here
green = 1
}
if blueSwitch.isOn { error here
blue = 1
}
let color = UIColor(red: red, green: green, blue: blue, alpha: 1)
colorView.backgroundColor = color
}
}