This question already has an answer here:
I have a UITextField set up to show a number pad. How do I require the user to enter exactly 5 digits?
I poked around and saw I should use shouldChangeCharactersInRange
but I'm not quite understanding how to implement that.
Make yourself a delegate of
UITextFieldDelegate
and implement the following:I'd just use this when the user leaves the textfield/validates with a button
Now if you want to count the chars WHILE the user is typing, you might use in
viewDidLoad
Please make sure to ask questions in the comments if you need more help :)