Possible Duplicates:
How to check if NSString is numeric or not
iphone how to check that a string is numeric only
I would like to validate a UITextField input.
I want that the input must be a double, and I want to detect if there are any strange characters as "()? etc.
Is there an easy way to detect that the input is a correct double better than the following?
if ([amount doubleValue] <= 0.0f)
I think you must validate “amount” string value before casting it to double, for example you can check if it contains “.” or something else … Or you do conversation in try catch and if your string will contain “(” or “()” or … it will catch exception.