我正在从 API 解析一堆 json 对象并将其放入 TableView 中。当我点击一行时,我希望它从数组中解析 API 中的对象并将其转发到另一个 View ,以便获得更多详细信息。
如果我按照我认为的方式将代码放在 cellForRowAtIndexPath 中,一切都很好,但是当我将 NSLog 放入 didSelectRowAtIndexPath 并让他显示我为特定行解析的 ID 时,我什么也得不到?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *neuheitenCell = @"neuheitenCell";
CJHomeTableCell *cell = [tableView dequeueReusableCellWithIdentifier:neuheitenCell];
sstring = [[idArray objectAtIndex:indexPath.row] objectForKey:@"ware_id"];
//NSLog(@"Selected item with id: %@",sstring);
return cell;
}
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"stuff: %@", sstring);
}
提前致谢
最佳答案
因为您使用了 didDeselectRowAtIndexPath:
而不是 didSelectRowAtIndexPath:
。
注意拼写。
关于ios - 解析 JSON objectAtIndexPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19559675/