Next, I'm now starting with Swift and iOS programming. I have a question: how to validate 2 different textFields? For example, I managed with the code below to do the validation of 1 single field, but the problem that my application has 4 fields and this validation is counting the characters of all fields. Type, if the textField that I put there in the "return" reaches the maxCharCount, in addition to locking this textField, it locks all the next ones as well. How do I validate each field separately?
func textField(_ shouldChangeCharactersIntextField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
return textField.text!.characters.count + string.characters.count <= self.maxCharCount
}
I have tried in several ways: create a function for each textField, join the 4 textfields inside the return, if chained, all xcode complains or does not work the right way. Has anyone been through this and would you be able to help me?