Methode funktioniert nicht immer

  • Methode funktioniert nicht immer

    Hallo zusammen,
    ich hab das Problem, dass eine Methode ab und zu funktioniert (was natürlich merkwürdig ist).
    Der Code sieht wie folgt aus

    Quellcode

    1. CPTScatterPlot* xAchse = [[[CPTScatterPlot alloc] initWithFrame:graphView.bounds] autorelease];
    2. xAchse.identifier = @"xAchse";
    3. xAchse.dataSource = self;
    4. CPTPlotSymbol *greenCirclePlotSymbol = [CPTPlotSymbol ellipsePlotSymbol];
    5. greenCirclePlotSymbol.fill = [CPTFill fillWithColor:[CPTColor greenColor]];
    6. greenCirclePlotSymbol.size = CGSizeMake(10.0, 10.0);
    7. xAchse.plotSymbol = greenCirclePlotSymbol;
    8. if (enabled == TRUE)
    9. [graph addPlot:xAchse];
    10. else
    11. [graph removePlotWithIdentifier:@"xAchse"];
    Alles anzeigen


    Es wird ein Plot angelegt. Wenn enabled == FALSE übergeben wird, soll er den Plot aus dem Graphen entfernen.
    Manchmal tut es das auch, aber manchmal auch nicht. Weiß jemand warum?

    Gruß
    Damasus
  • das mit dem Pointer auf Graph dachte ich zunächst auch, aber folgenden Methode funktioniert



    Quellcode

    1. - (void) zeichneTangente:(CPTGraphHostingView*)graphView enabled:(BOOL)enabled {
    2. CPTMutableLineStyle *plotlineStyle = [CPTLineStyle lineStyle];
    3. plotlineStyle.lineColor = [CPTColor redColor];
    4. plotlineStyle.lineWidth = 2.0f;
    5. if (next <= [tangentenwerte count]-3) {
    6. [graph removePlotWithIdentifier:@"tangente"];
    7. oldNext = next;
    8. CPTScatterPlot* tangente = [[[CPTScatterPlot alloc] initWithFrame:graphView.bounds] autorelease];
    9. tangente.identifier = @"tangente";
    10. tangente.dataSource = self;
    11. tangente.dataLineStyle = plotlineStyle;
    12. if (enabled == TRUE)
    13. [graph addPlot:tangente];
    14. else
    15. [graph removePlotWithIdentifier:@"tangente"];
    16. next += 3;
    17. }
    18. }
    Alles anzeigen