我有以下JSON数据,这是来自我的Web服务的响应。如何在UITableView中显示JSON数据
{"d": [{"raumKlassenObject":"Telepresenzraum"},
{"raumKlassenObject":"Besprechungsraum"},
{"raumKlassenObject":"Videokonferenzraum"},
{"raumKlassenObject":"IT-Schulungsraum"},
{"raumKlassenObject":"Konferenzraum"}]}
如何在TableView中显示数据Telepresenzraum,Besprechungsraum等...。
继承人我的代码到目前为止。
- (void)viewDidLoad
{
[super viewDidLoad];
dic = [NSJSONSerialization JSONObjectWithData:result options:kNilOptions error:nil];
array = [dic allKeys];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return array.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.textLabel.text=[NSString stringWithFormat:@"%@",[dic objectForKey:@"d"]];
return cell;
}
如果我这样做,在泰伯维输出
[{"raumKlassenObject":"Telepresenzraum"},{"raumKlassenObject":"Besprechungsraum"},{"raumKlassenObject":"Videokonferenzraum"},{"raumKlassenObject":"IT-Schulungsraum"},{"raumKlassenObject":"Konferenzraum"}]
我不知道如何在tableview中的行只显示Telepresenzraum,Besprechungsraum,Videokonferenzraum等。
Thx寻求帮助。
thx它的工作。多谢 – Bashud