IOS determines that NSString only contains numbers
// Determine whether it is an integer:
-(BOOL) isPureInt :( NSString *) string {
Ns‑* scan = [ns‑scannerwithstring: string];
Int val;
Return [scan scanInt: & val] & [scan isAtEnd];
}
// Determine whether it is a floating point:
-(BOOL) isPureFloat :( NSString *) string {
Ns‑* scan = [ns‑scannerwithstring: string];
Float val;
Return [scan scanFloat: & val] & [scan isAtEnd];
}
If (! [Self isPureInt: textField. text] |! [Self isPureFloat: textField. text]) {
TextField. textColor = [UIColor redColor];
TextField. text = @ "Warning: contains invalid characters. Please enter a pure number! ";
Return;
} Else {
TextField. textColor = [UIColor blackColor];
If ([textField. text integerValue]> self. moneyT ){
[SMAlertView showAlert: [NSString stringWithFormat: @ "the refund amount cannot exceed the total amount of money bag % ld. Please enter", (long) self. moneyT] again;
TextField. text = nil;
} Else {
Self. money = textField. text;
}
}