#pragma mark -- TextField代理
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
/*
// Method - one
int limit = 3;
return !([textField.text length] > limit && [string length] > range.length);
*/
// Method - two
if (textField == self.passWordLabel) {
if (range.length + range.location > textField.text.length) {
return NO;
}
NSUInteger newLength = [textField.text length] + [string length] - range.length;
return newLength <= ;
}
return YES;
}
Method - one 比较绕