I am creating a trivia application that asks for a username on start up. I\'d like to make it impossible to use characters such as #$@!^& etc (also including \"space\").
Swift 2.3
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool { let characters = ["#", "$", "!", "&","@"] for character in characters{ if string == character{ print("This characters are not allowed") return false } } }