Created
March 30, 2018 13:51
-
-
Save rtking1993/9d118e0a3539680c67eb77eb30184cd7 to your computer and use it in GitHub Desktop.
The body methods of the MainViewController for our dynamic list
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
// MARK: View Methods | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
loadItems() | |
} | |
// MARK: Action Methods | |
@IBAction func add(_ sender: Any?) { | |
guard let itemText = addTextField.text else { | |
return | |
} | |
textFieldFinished() | |
let item: Item = Item(item: itemText) | |
ItemsRemote.postItem(item: item) | |
} | |
// MARK: Helper Methods | |
private func loadItems() { | |
ItemsRemote.getAllItems { items in | |
self.items = items | |
} | |
} | |
private func textFieldFinished() { | |
addTextField.text = nil | |
addTextField.resignFirstResponder() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment