I am developing an iOS app and I want to check wether the string in the textfield is a NaN
.
I am using the following code, I am calling this code inside button click:
int incrby = [self.valueField.text intValue];
if (isnan(incrby)) {
[[[UIAlertView alloc] initWithTitle:@"" message:@"Enter a valid number for the increment" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
[self.valueField becomeFirstResponder];
return;
}
But the above code is not working. By not working I mean if I enter a NaN value it does not show alert.
For eg: if I enter hey
or hey3
it should show alert
I dont want to make the textfield as number only (show numberpad only).
I searched and found some examples but could not solve my problem
I am new to iOS and don't know what to do what I am doing wrong
Thanks in advance