How to catch a Nan?

Nan represents Not a number

When it happens to get a Nan as a result of an expression you have to find a way to catch it before.

Let’s think an if statement and inside this the appropriate check.

A working code is the following:

if ([[NSDecimalNumber decimalNumberWithString:self.price...] isEqual:[NSDecimalNumber notANumber]]) {

....

}

Leave a Reply

Your email address will not be published. Required fields are marked *