Shinobidatagrid with unpredictable crash whenever accessing and scrolling it


#1

the shinobidatagrid implementation i has unpredictable crash whenever accessing it or trying to scroll it it seems that the array is out of bounds.

- (void)shinobiDataGrid:(ShinobiDataGrid *)grid prepareCellForDisplay:(SDataGridCell *)cell
{
    // both columns use a SDataGridTextCell, so we are safe to perform this cast
    SDataGridTextCell* textCell = (SDataGridTextCell*)cell;
   
    DelEquipment *delequipment=_sortedData[cell.coordinate.row.rowIndex];<br><br><br>stacktrace<br><br><br>







***Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 2 beyond bounds [0 .. 1]'
*** First throw call stack:
(
	0 CoreFoundation 0x03d5c5e4 __exceptionPreprocess + 180
	1 libobjc.A.dylib 0x031668b6 objc_exception_throw + 44
	2 CoreFoundation 0x03d109c2 -[__NSArrayI objectAtIndex:] + 210
	3 CoreFoundation 0x03ddb608 -[NSArray objectAtIndexedSubscript:] + 40
	4 TMS 0x0041cfda -[DelEquipments shinobiDataGrid:prepareCellForDisplay:] + 458
	5 TMS 0x008717ff -[ShinobiDataGrid shinobiGrid:cellForGridCoord:] + 255
	6 TMS 0x0085e1be -[SGridDataSourceDelegateManager loadAndRetrieveCellAtCol:atRow:] + 574
	7 TMS 0x00834c90 -[ShinobiGrid loadAndRetrieveCellAtCol:atRow:] + 96
	8 TMS 0x0084f187 -[ShinobiGrid topCellToBeAddedForCol:] + 311
	9 TMS 0x00850056 -[ShinobiGrid addNewTopRowToGrid] + 390
	10 TMS 0x00850c76 -[ShinobiGrid removeRowsFromBottomAddToTopIfNeeded] + 1014
	11 TMS 0x00851011 -[ShinobiGrid manageTopAndBottomEdgeCells] + 865
	12 TMS 0x0082aca0 -[ShinobiGrid scrollViewDidScroll:] + 1776
	13 UIKit 0x01d5395b -[UIScrollView(UIScrollViewInternal) _notifyDidScroll] + 62
	14 UIKit 0x01d3dc43 -[UIScrollView setContentOffset:] + 734
	15 TMS 0x00825022 -[SGridLayer setContentOffset:] + 178
	16 UIKit 0x01d4ead2 -[UIScrollView _smoothScrollWithUpdateTime:] + 4009
	17 UIKit 0x01d4eda9 -[UIScrollView _smoothScrollDisplayLink:] + 222
	18 QuartzCore 0x01bc9b8a _ZN2CA7Display15DisplayLinkItem8dispatchEv + 48
	19 QuartzCore 0x01bc9a46 _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 310
	20 QuartzCore 0x01bc9f6b _ZN2CA7Display16TimerDisplayLink8callbackEP16__CFRunLoopTimerPv + 123
	21 CoreFoundation 0x03d1abd6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
	22 CoreFoundation 0x03d1a5bd __CFRunLoopDoTimer + 1181
	23 CoreFoundation 0x03d02628 __CFRunLoopRun + 1816
	24 CoreFoundation 0x03d01ac3 CFRunLoopRunSpecific + 467
	25 CoreFoundation 0x03d018db CFRunLoopRunInMode + 123
	26 GraphicsServices 0x047009e2 GSEventRunModal + 192
	27 GraphicsServices 0x04700809 GSEventRun + 104
	28 UIKit 0x01cc7d3b UIApplicationMain + 1225
	29 TMS 0x0011fe1d main + 141
	30 TMS 0x00002a05 start + 53
	31 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

#2

This is an issue of passing an index 2 to an array with count 2.

Also, if you have 2 columns, you should be passing the column index, instead of the row index.