Search code examples
iosobjective-ccocoa-touchcore-plot

Core Plot Thread Error - EXC_BAD_ACCESS (code=1, address=0x400002122)


My am using Core Plot Framework version 2 in my app. I am facing error following method "plotRangeWithLocation:CPTDecimalFromInt" CPTDecimalFromInt returning null value.

Core Plot space Creation

//Add plot space
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;

// coreplot change
plotSpace.delegate = self;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInt(0.0)
                                                length:CPTDecimalFromInt(10)];    
plotSpace.yRange  = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInt(0)
                                                 length:CPTDecimalFromInt([self getMaxYValue])];*/

Getting Crash in Below code

+ (instancetype)plotRangeWithLocation:(NSNumber *)loc length:(NSNumber *)len {
    return [[self alloc] initWithLocation:loc length:len];
}

Solution

  • The Core Plot API changed slightly in 2.0. The +plotRangeWithLocation:length: method now takes NSNumber objects as parameters instead of NSDecimal values.

    See this wiki page for a summary of the changes between 1.x and 2.0.