我正在做一个条件语句来检查文本字段是否包含某些字符,如果是,它们将显示 UIAlertView。目前,如果文本字段包含字母,则会显示警报,我将如何扩展下面的方法以包含诸如?!, $ 等
if ([self.withdrawTextField.text rangeOfCharacterFromSet:[NSCharacterSet letterCharacterSet]].location != NSNotFound) {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Ooops" message:@"Please only use numbers and the period (.)." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}