I would like to limit the characters in textField
of IOS Application. I tried all the methods given in Stack Overflow, so I am asking this question.
Here I used one Label (secure code) and one textfield (5 characters).
I had given the below code in viewcontroller.m
file, but not working.
myTextField.delegate = self
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSString *newString = [textField.text stringByReplacingCharactersInRange:range withString:string];
return !([newString length] > 5);
}