0
我得到一个回响应从Web服务API像这样:在LeafViewController
表做什么
{
"springs": [{
"name": "springName",
"leafs": [{
"name": "leafName",
"towns": [{
"name": "townName",
},{
"name": "leafName2",
},{
我列出了所有Leafs
的查看,如果Leaf
有与之关联的Towns
的列表,则会跳转到TownViewController
表格视图以列出关联的Towns
。
我有所有正确的在我的cellForRowAtIndexPath
:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"standardCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
Spring *spring = [springs objectAtIndex:indexPath.section];
Leaf *leaf = [sport.leafs objectAtIndex:indexPath.row];
cell.textLabel.text = leaf.shortName;
return cell;
}
我的问题是,有时候没有与Leaf
相关Town
,在这种情况下,我需要检查所以如果Leaf
细胞按下后,我可以弹回到主视图控制器,而不是转到列出Town
的下一个视图控制器。
现在,如果我选择一个Leaf
单元格,并且没有Town
s与之相关联,则它会继续到空白的TownViewController
,因为没有任何城镇关联。
如何检查JSON响应,以便我知道是继续访问下一个TownViewController还是回到MainViewController
?
我可以发布任何额外的代码,谢谢你的帮助!
感谢您的回应!这很有道理,我今晚会给它一个镜头 - – Realinstomp