我正在解析JSON到我的MASTER-DETAIL应用程序,并在将“深入挖掘”到JSON中时出现问题。我无法获取我的detailTableView
中的数据。 在我的detailTableView
中,我想要命名酒店/ pousadas。无法从我的JSON中获取所有数据
见我的JSON和detailTableView.m:
[
{
"title": "Where to stay",
"pousadas":
[
{
"beach": "Arrastão",
"name": "Hotel Arrastão",
"address": "Avenida Dr. Manoel Hipólito Rego 2097",
"phone": "+55(12)3862-0099",
"Email": "[email protected]",
"image": "test.jpg",
"latitude": "-23.753355",
"longitude": "-45.401946"
}
]
}
]
而且在的tableView detailTableView.m:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return self.stayGuide.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"detailCellStay"];
这里是我的选拔赛:
NSString *pous = [self.stayGuide valueForKey:@"name"];
NSLog([self.stayGuide valueForKey:@"name"]);
cell.textLabel.text = pous;
return cell;
}
提前感谢!
您有一个包含字典有两个元素,一个元素的数组 - “标题”和“Pousadas酒店”。 “pousadas”又是一个包含一个元素的数组。这一个元素是一个包含其余数据的字典。剥洋葱,一次一层。 (NSLog是你的朋友 - 它将呈现与原始JSON非常相似的中间数据视图,从而可以轻松查看每个步骤下一步需要执行的操作。) – 2013-02-21 23:10:23