我正在实现委托方法:
-(BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
我在我的应用程序中使用了以下代码。但是,我收到了警告,我不知道为什么。我的代码如下:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
if (textField.tag == 1) {
if(blah blah blah)
return YES;
//more code
if (blah blah) {
//more code
}
else if (blah blah) {
//more code;
}
else if (blah blah blah) {
//more code
}
//even more code
return NO;
}
else if (textField.tag == 2){
if(textField.text.length > 1) {
return NO;
}
return YES;
}
else if (textField.tag == 3) {
if(textField.text.length > 2) {
return NO;
}
return YES;
}
}
我得到的警告是:
“控制可能达到非无效功能的终点。” 我在每个“if”子句的末尾都有返回值,那么为什么我仍然收到这个警告?