Last active
March 26, 2017 04:13
-
-
Save lizixroy/dde278465a4736f4466e364c5a6f89fe to your computer and use it in GitHub Desktop.
blog
This file contains hidden or 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
func submitButtonPressed { | |
showLoadingWheel() | |
defer { hideLoadingWheel() } | |
guard validateInput() else { | |
hideLoadingWheel() | |
showErrorAlert() | |
return | |
} | |
} | |
func validateInput -> Bool { | |
guard let username = self.usernameField.text else { return false } | |
let trimmedUsername = username.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) | |
guard trimmedUsername.length > 0 else { return false } | |
let payload = ["username": trimmedUsername]; | |
webService.sendPOSTRequest(withPayload: payload) | |
return true | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment