ShinobiDataGrid reloadRows causing crash


I’ve run into a strange error while using ShinobiDataGrid. I’ve successfully implemented a working grid in another ViewController in this app, but for some reason, on a nearly identicaly second ViewController, “reloadRows:” is causing a crash. The flow works like this:

  1. User begins editing a cell

  2. User exits the cell

  3. My delegate’s shinobiDataGrid:didFinishEditingCellAtCoordinate: method is called, in which reloadRows: is called, followed by a crash.

I’ve made my method as simple as this:

-(void)shinobiDataGrid:(ShinobiDataGrid *)grid didFinishEditingCellAtCoordinate:(SDataGridCoord *)coordinate
    [_gridView reloadRows:@[coordinate.row]];

…but shortly after I get this error (with NSZombiesEnabled to debug BAD_ACCESS exception):

[SGridAutoCell prepareToAcceptEditEvents:]: message sent to deallocated instance 0x13488310

All of my cells are actually SDataGridTextCells, so I can’t figure out why there is even an instance of SGridAutoCell attempting to do anything. If I delay the call to reloadRows by even a fraction of a second using performSelector:withObject:afterDelay, the problem does not occur. (However, it creates its own set of problems, particularly if the user wants to tap another cell to edit it, he gets kicked out of editing mode once the reloadRows: fires.)

Any ideas what could be causing this? I’m on iOS 6.1.


It turns out my working ViewController only worked because I was using custom cells that contained “SelectViews” (essentially dropdowns.) It seems you cannot call reloadRows: inside shinobiDataGrid:didFinishEditingCellAtCoordinate: because the cell you are working in is getting deallocated and subsequently accessed due to the order of events. My custom cells got around this because they were not using the standard mechanism for editing, that being using the default UITextField in the cell.

So, for my particular use case, which was to update the values of formulas in other cells on the same row based on the edits I was making, I opted to use reloadColumns: instead. Although this reloads data in all visible rows and not just the row I am currently editing, I believe it will not impact performance, so it’s a decent way to move forward. My calculations are occurring, and my formula cells are refreshing with the proper values. I hope this helps someone else who stumbles across this.


Yes it does! Thanks


Yes it does! Thanks