stackIndex crash (2)


#1

I have a reproducible crash when using stackIndex with SChartColumnSeries with version 2.8.6. This happens when the numberOfDataPointsForSeriesAtIndex is zero.

 

To reproduce go to the column series sample in the swift folder.

Update the following code…

 

    // MARK:- SChartDatasource Functions

    

    // Two series of data (2013 and 2014 sales data)

    func numberOfSeriesInSChart(chart: ShinobiChart!) -> Int {

        return 1

    }

    

    // Create column series objects for both sets of data and assign relevant title

    func sChart(chart: ShinobiChart!, seriesAtIndex index: Int) -> SChartSeries! {

        let columnSeries = SChartColumnSeries()

        columnSeries.title = (index == 0 ? “2013” : “2014”)

        columnSeries.stackIndex = NSNumber(int: 101)

        return columnSeries

    }

    

    // Number of datapoints in series is equivalent to number of grocery items for year at seriesIndex

    func sChart(chart: ShinobiChart!, numberOfDataPointsForSeriesAtIndex seriesIndex: Int) -> Int {

        return 0

        //return salesData[seriesIndex].count

    }

 

 

 

*** Terminating app due to uncaught exception ‘NSRangeException’, reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array’

*** First throw call stack:

(

0   CoreFoundation                      0x000000010c14be65 __exceptionPreprocess + 165

1   libobjc.A.dylib                     0x000000010dec3deb objc_exception_throw + 48

2   CoreFoundation                      0x000000010c02f404 -[__NSArrayM objectAtIndex:] + 212

3   ColumnSeries                        0x000000010b63b9f2 -[SChartSeriesDataPointFinder initWithSeries:] + 194

4   ColumnSeries                        0x000000010b5c9d07 -[SChartCartesianSeries mapWithStackedSeries:onChangedAxis:andMeasuredAxis:] + 2311

5   ColumnSeries                        0x000000010b56c45e -[SChartColumnSeries mapWithStackedSeries:onXAxis:andYAxis:] + 78

6   ColumnSeries                        0x000000010b5d26d7 -[SChartCartesianSeriesGroup mapSeries] + 3463

7   ColumnSeries                        0x000000010b5bfc88 -[ShinobiChart groupAndMapSeries:] + 904

8   ColumnSeries                        0x000000010b5c1fdb -[ShinobiChart layoutSubviews] + 779

9   UIKit                               0x000000010ca1f4a3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703

10  QuartzCore                          0x000000010b95459a -[CALayer layoutSublayers] + 146

11  QuartzCore                          0x000000010b948e70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366

12  QuartzCore                          0x000000010b948cee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24

13  QuartzCore                          0x000000010b93d475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277

14  QuartzCore                          0x000000010b96ac0a _ZN2CA11Transaction6commitEv + 486

15  QuartzCore                          0x000000010b96b37c _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92

16  CoreFoundation                      0x000000010c077367 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23

17  CoreFoundation                      0x000000010c0772d7 __CFRunLoopDoObservers + 391

18  CoreFoundation                      0x000000010c06c84c CFRunLoopRunSpecific + 524

19  UIKit                               0x000000010c9637cd -[UIApplication _run] + 402

20  UIKit                               0x000000010c968610 UIApplicationMain + 171

21  ColumnSeries                        0x000000010b50459d main + 109

22  libdyld.dylib                       0x000000010f9bd92d start + 1

)

libc++abi.dylib: terminating with uncaught exception of type NSException


#2

Hi Charlie,

I’ve responded to your email and we’re looking into this at the minute. I’ll make sure to update this post once the fix has been done.

Matt


#3

Hi Charlie,

I’ve responded to your email and we’re looking into this at the minute. I’ll make sure to update this post once the fix has been done.

Matt