Last active
February 2, 2020 14:32
-
-
Save ambientlight/443248e0b74765cc7d531ac9c26864b2 to your computer and use it in GitHub Desktop.
Crude counter view controller
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
var appState = 0 | |
let reducer: (Int, Int) -> Int = { (sum, increment) in sum + increment }; | |
class CounterViewController: UIViewController { | |
@IBOutlet var inputField: UITextField! | |
@IBOutlet var addButton: UIButton! | |
@IBOutlet var sumLabel: UILabel! | |
@IBAction func addButtonPressed(_ sender: UIButton) { | |
appState = reducer(appState, Int(self.inputField.text!)!) | |
self.sumLabel.text = "\(appState)" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment