I am drawing pie-charts using HighChart Library (Pie-chart). While Passing data to chart my code is like this :
pie.data = [NSMutableArray arrayWithObjects:@{
@"name": @"New Jersey",
@"y": self->numPlusNJ
},
@{
@"name": @"Miami FLG",
@"y": self->numPlusMiamiFLG
},
@{
@"name": @"Chicago",
@"y": self->numPlusChicago
},nil];
where the values like self->numPlusNJ are NSNumbers. Sometimes after calculations value like 0(zero) comes in NSNumbers and it is taking those values as NAN. In those cases I am getting this error while drawing pie-chart :
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid number value (NaN) in JSON write'.
I tried to Replace NAN value by 0 like this :
if(isnan([self->numRPercentNJ doubleValue])){self->numRPercentNJ = 0;}
But in that case I am getting can't insert nil in dictionary object.
So, Currently I am unsure about how to replace this NAN value by something in order to avoid crash.