0

我的 indexPath.row 有问题,当我尝试访问此变量时,我的应用程序崩溃并且控制台上没有错误:(

代码是这样的:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here. Create and push another view controller.
    NSLog(@"%@", indexPath); //works fine
    NSLog(@"%@", indexPath.row); //crash
}

我在 ModalViewController 中使用它。

4

1 回答 1

2

你必须使用

NSLog(@"%d", indexPath.row);

代替

NSLog(@"%@", indexPath.row);

这是因为, indexpath.row 是一个整数,你必须使用 %d 。

于 2010-10-11T08:05:24.617 回答