在EChart库中获取错误[__NSCFString value]

时间:2014-08-18 06:21:19

标签: ios charts

我正在使用EChart库,尝试在iPad上制作条形图。我确实在演示项目中做了所有事情,但收到了错误:

-[__NSCFString value]: unrecognized selector sent to instance 0x8bba220
2014-08-18 08:28:44.684 STAT_V2_iPAD[19187:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString value]: unrecognized selector sent to instance 0x8bba220'

以下是调试后的错误代码:

/** The highest value among the whole chart*/
- (EColumnDataModel *) highestValueEColumnChart:(EColumnChart *) eColumnChart{
    EColumnDataModel *maxDataModel = nil;

     float maxValue = -FLT_MIN;
     NSLog(@"After FLT_MIN : %.f",FLT_MIN);

     for (EColumnDataModel *dataModel in MergedArr)
     {
     NSLog(@"Data.Value = %f",dataModel.value);
     if (dataModel.value > maxValue)
     {
     NSLog(@"inside ifd");
     maxValue = dataModel.value;
     maxDataModel = dataModel;
     }
     }
     NSLog(@"Finished MAX %.f",maxDataModel.value);

    return maxDataModel;
}

1 个答案:

答案 0 :(得分:0)

问题是您的dataModel保留NSString而不是EColumnDataModel。下面的答案将防止崩溃,但你需要找到字符串是如何发生的?

 -(EColumnDataModel *) highestValueEColumnChart:(EColumnChart *) eColumnChart{
        EColumnDataModel *maxDataModel = nil;

         float maxValue = -FLT_MIN;
     NSLog(@"After FLT_MIN : %.f",FLT_MIN);

     for (EColumnDataModel *dataModel in MergedArr)
     {
if([dataModel isKindOfClass:[EColumnDataModel class]]){
     NSLog(@"Data.Value = %f",dataModel.value);
     if (dataModel.value > maxValue)
     {
     NSLog(@"inside ifd");
     maxValue = dataModel.value;
     maxDataModel = dataModel;
     }
}
     }
     NSLog(@"Finished MAX %.f",maxDataModel.value);

    return maxDataModel;
}