After a couple of beta testers found a weird behaviour in a new beta version of an application, I eventually tracked it down to the problem only occurring with PPC Macs, and then down to the following line of code:
if ( [[[thing amount] num2] floatValue] > 0.0 )
This worked fine on Intel Macs, but not on PPC Macs.
[[thing amount] num2] returns an NSNumber and the problem appears to occur when it returns nil. So a simple check for nil added to the logic fixed it completely, as shown below:
if ( [[thing amount] num2] && [[[thing amount] num2] floatValue] > 0.0 )
Surely this is absurd? Surely [<nil expression> floatValue] > 0.0 should always return NO/FALSE???? And therefore the addition should do nothing?
But I can assure you that in this case the addition fixes the problem completely.
Can anyone enlighten me as to why this behaviour occurs?