Memory error at numberOfSeriesInSChart while using ARC


I’ve been trying to add my ShinobiChart as a subview to a UIView that is a subview to a scrollview. However I am getting a exec_bad_access error whenever I try to add the chart to the view. After using the nszombieenabled enviroment variable I get an error in the log that says [ChartDataSource numberOfSeriesInSChart:]: message sent to deallocated instance … I’m using arc and haven’t released anything mannually. I’ve used this exact chart and datasource in its own viewcontroller before without any problems, I only get this problem when I move it over to this custom view. Has anyone run into this problem before?


Figured this one out. The datasource object that is used must be declared a strong property so its not released after being assigned to the chart datasource.


I had the same crash after converting the app to ARC.

I was using a custom uitableviewcell and adding a subview to the custom cell that has a view controller. The view controller that is being added to the custom table cell was a Chart Data Source. After converting to ARC, I started getting exc_bad_access. I had to add the view controller as a strong variable to the custom tableviewcell so that the custom view controller does not get released and cause a crash. 

            MeasureAllCell *cell = (MeasureAllCell *) [tableView dequeueReusableCellWithIdentifier:@"MeasureAllCell"];
            if (cell == nil) {
                NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"MeasureAllCell" owner:self options:nil];
                cell = (MeasureAllCell *)[nib objectAtIndex:0];
                 MeasureAllViewController *mwController1 = [[MeasureAllViewControlleralloc] initWithNibName:@"MeasureAllViewController"bundle:nil];
                cell.vwControllerMeasure = mwController1;// ADDED THIS LINE TO FIX THE CRASH
                mwController1.btnBG.tag = [indexPath row];
                 [mwController1.btnBGaddTarget:selfaction:@selector(selectedMeasure:) forControlEvents:UIControlEventTouchUpInside];
                mwController1.lblTitle1.text = [self.measuresArray objectAtIndex:mwController1.btnBG.tag];
                mwController1.cellTitle = [self.measuresArray objectAtIndex:mwController1.btnBG.tag];
                [cell.vwMeasure addSubview:mwController1.view];
            return cell;