I am doing the comparison:
else if([change doubleValue] == 0 && indexPath.row == sectionRows - 1)
how can I check for the case where [change doubleValue] doesn't return anything?
I am doing the comparison:
else if([change doubleValue] == 0 && indexPath.row == sectionRows - 1)
how can I check for the case where [change doubleValue] doesn't return anything?
There's no way the doubleValue
method goes without returning anything. The least value you can check for is 0
. The following are the cases the doubleValue returns 0.
string
doesn't contain a valid numerical value. string
is nil
.string
actually contains @"0"
.Checking for a valid number
Use NSPredicate to test if the string contains a numerical value.
NSString *str = @"sfas";
NSString *regx = @"(-){0,1}(([0-9]+)(.)){0,1}([0-9]+)";
NSPredicate *test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regx];
BOOL isAValidNumber = [test evaluateWithObject:str];