Simple and practical textField input length verification (iOS)

created at 11-15-2021 views: 3

Implement proxy method

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    if (textField == self.nameTextField) {
       if (range.location  > 14) {
           return NO;
       }
    }
    if (textField == self.cardTextField) {
       if (range.location  > 17) {
          return NO;
       }
    }
    return YES;
}
created at:11-15-2021
edited at: 11-15-2021: