我在这里定义了这个变量:
const SDataGridCoord *clickedGridCoord;
我用这种方法填充它:
- (void)shinobiDataGrid:(ShinobiDataGrid *)grid willSelectCellAtCoordinate:(const SDataGridCoord *)gridCoordinate
{
if ((gridCoordinate.column.displayIndex==5||gridCoordinate.column.displayIndex == 6 || gridCoordinate.column.displayIndex == 7 ) && dataSource.dataForDatabase)
{
clickedGridCoord = gridCoordinate;
[self CreateCellDateModPopup:gridCoordinate];
}
}
我使用了一个断点并看到它被填充了。
但是当我调用它时,它是空的:
CellData *cell = [dataSource.cellHolder objectAtIndex:clickedGridCoord.row];
空的意思是没有行或列,但是当我第一次填充 SDataGridCoord 时。
我做错了什么,没有其他东西可以覆盖变量。
我试过这个:
SDataGridCoord *clickedGridCoord;
然后
- (void)shinobiDataGrid:(ShinobiDataGrid *)grid willSelectCellAtCoordinate:(const SDataGridCoord *)gridCoordinate
{
if ((gridCoordinate.column.displayIndex==5||gridCoordinate.column.displayIndex == 6 || gridCoordinate.column.displayIndex == 7 ) && dataSource.dataForDatabase)
{
clickedGridCoord = (SDataGridCoord *)gridCoordinate;
[self CreateCellDateModPopup:gridCoordinate];
}
}
结果仍然相同,我的应用程序仍然崩溃:线程 1:EXC_BAD_ACCESS (code = 1, address=0xc000000c)
我的 .m 文件:
@interface Controller()
{
SDataGridCoord *clickedGridCoord;
}
@implementation Controller
- (void)shinobiDataGrid:(ShinobiDataGrid *)grid willSelectCellAtCoordinate:(const SDataGridCoord *)gridCoordinate
{
if ((gridCoordinate.column.displayIndex==5||gridCoordinate.column.displayIndex == 6 || gridCoordinate.column.displayIndex == 7 ) && dataSource.dataForDatabase)
{
clickedGridCoord = (SDataGridCoord *)gridCoordinate;
[self CreateCellDateModPopup:clickedGridCoord];
}
}
- (void)ChangeCellWithStringDate :(NSString *)stringDate
{
//My app crashes here with this error: Thread 1:EXC_BAD_ACCESS (code = 1, address=0xc000000c)
CellData *cell = [dataSource.cellHolder objectAtIndex:clickedGridCoord.row.rowIndex];
}