Friday, 16 August 2013

My method always seems to return FALSE

My method always seems to return FALSE

This method:
- (BOOL)checkForDigits {
NSString *editableExpression = self.expression.text;
for (int i = 0; i < editableExpression.length; i++){
char charAtPosition = [editableExpression characterAtIndex:i];
for (int c = 0; c < 10; c++ ){
char digitAtPosition = digits[c];
if (charAtPosition == digitAtPosition){
return TRUE;
}
else {
return FALSE;
}
}
}
}
always seems to return FALSE and I can't figure out why. I would have used
the isnan method but I tried that and it didn't work so I just made my own
isnan (really the opposite of isnan). The digits array is just
char digits[10] = {'1', '2', '3', '4', '5', '6', '7', '8', '9'};

No comments:

Post a Comment