我有一个表,当我选择一行时,我执行此命令:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
InfoClienteViewController *infoViewController = [[InfoClienteViewController alloc] init];
[self.navigationController pushViewController:infoViewController animated:YES];
[infoViewController setIdt:idt[indexPath.row]];
NSLog(@"You Select -> %zd",idt[indexPath.row]);
}
Run Code Online (Sandbox Code Playgroud)
在我的数组(idt)中我有这个值:
所以,当我点击我表格的第一行(现在indexPath.row为[0])时,NSLog显示数字2,但返回数字4451524096,为什么?我该如何解决?
数组不能容纳普通号码(基本数据类型,如int,float,NSInteger,...),他们只能持有的对象.因此,当您idt[indexPath.row]以普通数字登录时,您会感到胡言乱语.
你的日志应该是:
NSLog(@"You Select -> %@", idt[indexPath.row]);
Run Code Online (Sandbox Code Playgroud)
正确记录对象.