开发者

Crash when using indexPath.row in a modalViewController

开发者 https://www.devze.com 2023-01-19 06:23 出处:网络
I\'ve a problem with indexPath.row, when I try to acce开发者_JS百科ss this variable my app crashes and I get no errors on the console :(

I've a problem with indexPath.row, when I try to acce开发者_JS百科ss this variable my app crashes and I get no errors on the console :(

the code is this:

- (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
}

and I'm using it inside a ModalViewController.


You have to use

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

instead of

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

This is because, indexpath.row is an integer and you have to use the %d .

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号