/ / crash su CPTScatterPlotDelegate in CorePlot - cacao, core-plot

arresto anomalo su CPTScatterPlotDelegate in CorePlot - cacao, core-plot

Sto cercando di sovrapporre più grafici in un grafico e sto ottenendo arresti anomali (EXC_BAD_ACCESS) sul CPTScatterPlotDelegate di seguito in classe CPTScatterPlot.m

-(void)renderAsVectorInContext:(nonnull CGContextRef)context {
...
// Draw line
if ( theLineStyle ) {
CGPathRef dataLinePath = [self   newDataLinePathForViewPoints:viewPoints indexRange:viewIndexRange baselineYValue:CPTNAN];

// Give the delegate a chance to prepare for the drawing.
id<CPTScatterPlotDelegate> theDelegate = self.delegate;
....
}
...
}

Lo stesso in CPTLegendDelegate nella classe CPTPlot.m

-(void)drawSwatchForLegend:(nonnull CPTLegend *)legend atIndex:(NSUInteger)idx inRect:(CGRect)rect inContext:(nonnull CGContextRef)context
{
id<CPTLegendDelegate> theDelegate = (id<CPTLegendDelegate>)self.delegate;
...
}

Sto usando CorePlot 2.1 e ho modificato il renderInGraphHostingView nel file SimpleScatterPlot.m negli esempi / CorePlotGallery come segue:

-(void)renderInGraphHostingView:(nonnull CPTGraphHostingView *)hostingView withTheme:(nullable CPTTheme *)theme animated:(BOOL)animated {
...
static CPTGraph *graph = nil;
if( initialize ) {
graph = [[CPTXYGraph alloc] initWithFrame:bounds];
...
}
[self addGraph:graph toHostingView:hostingView];
theme = [CPTTheme themeNamed:kCPTDarkGradientTheme];
...
}

Quindi ogni volta che voglio disegnare una nuova linea di dati, utilizzo lo stesso grafico.

Il problema è casuale e qualche volta programmasi blocca quando disegno la seconda riga, a volte nella terza, ma funziona sempre bene per il primo grafico. Dipende anche dalla compilazione. Qualche idea? Grazie in anticipo

risposte:

1 per risposta № 1

Il delegate la proprietà contiene un riferimento debole all'oggetto delegato. Assicurarsi che il delegato non sia stato deallocato tra gli aggiornamenti del grafico.