Thanks a lot but how does this change how the code performs - is there anything specifically wrong with the code?
Impossible to tell. Too many unknowns.
First, you only provided code, not a crash-report stack-trace, so no one knows exactly where it crashed. Without knowing where it crashed, there's no way to know which expression is producing the NaN.
Do you know what NaN means? It means "Not a Number", so some calculation somewhere in your code is being performed with an invalid value, or is producing an invalid result. There can be any number of reasons for an invalid value or invalid result. That's why you have to narrow down the exact calculation that's producing the NaN.
Second, you only provided a code fragment, not a complete compilable program that someone else can run. If no one can run it, no one can discover exactly where it crashes, so no one can find the specific point where the NaN is coming from.
And frankly, you seem to be missing a #endif in the code you posted:
Code:
#if USE_CUSTOM_DRAWING
else
{
topLabel = (UILabel *)[cell viewWithTag:TOP_LABEL_TAG];
bottomLabel = (UILabel *)[cell viewWithTag:BOTTOM_LABEL_TAG];
}
return cell;
}
The last } shown above is the end of a method. If USE_CUSTOM_DRAWING is false, you have a big problem. If it's true, then you've probably made the entire rest of the file conditionally compiled. It may compile now, but it's wrong.