What is the NSNotFound Equivalent for Floats
2 answers
You can use non-number ( NaN
).
See nan()
, nanf()
and isnan()
.
However, for these problems, when there is no clear obscene value (which is worse with integers), I prefer to use the following method semantics:
- (BOOL)parseString:(NSString *)string
toFloat:(CGFloat *)value
{
// parse string here
if (parsed_string_ok) {
if (value)
*value = parsedValue;
return YES;
}
return NO;
}
+3
source to share