Make UILabel show "No results" instead of "nan"
Posted
by Mike Rychev
on Stack Overflow
See other posts from Stack Overflow
or by Mike Rychev
Published on 2010-04-04T08:54:30Z
Indexed on
2010/04/04
9:03 UTC
Read the original article
Hit count: 318
I have a small app, where user can make some calculations and solve equations. For example, if in a square equation discriminant is less than zero, the x1 and x2 values are "nan", so when I assign x1 and x2 values to UILabels they show "nan" as well. Writing a lot of if's like
if(D<0) [label setText:[NSString stringWithFormat: @"No solutions"]];
Doesn't help-there are too many cases. I want to check if after
[label setText:[NSString stringWithFormat: @"%f", x]];
label's value is "nan", the label's value will be set to @"No solutions".
Doing simple
if(label==@"nan") {
//code
}
doesn't help.
Thanks in advance!
© Stack Overflow or respective owner