我试图UIAlertView
在实际从 a 中删除一个单元格之前显示 aUITableView
NSIndexPath *_tmpIndexPath;
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(editingStyle == UITableViewCellEditingStyleDelete)
{
_tmpIndexPath = indexPath;
NSLog(@"%d", indexPath.row); // 2
NSLog(@"%d", _tmpIndexPath.row); // 2
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Dete" message:@"Are you sure you want to delete this entry?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil] autorelease];
[alert show];
}
}
所以我的两个日志都返回了正确的路径。
我有委托 UIAlertView 的观点
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"%d", _tmpIndexPath.row);
if(buttonIndex == 1)
{
NSLog(@"%d", _tmpIndexPath.row);
}
}
现在我无法弄清楚为什么在clickButtonAtIndex()
尝试登录时出现错误_tmpIndexPath.row
*** -[NSIndexPath row]: message sent to deallocated instance 0x12228e00