<pre>
products = (
{
id = 19;
"image_url" = "http://localhost:8888/straightoffer/image/data/1330374078photography.jpg";
name = "Save $240 on your next photo session";
},
{
id = 21;
"image_url" = "http://localhost:8888/straightoffer/image/data/1330373696massage.jpg";
name = "One Hour Massage";
}
);
}
</pre>
以上是我通过json得到的,我需要将值分配给uitableviews:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
NSLog(@"行数:%d",[[products objectForKey:@"products"] count]);
返回 [[products objectForKey:@"products"] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
如果(细胞 == 零){
单元格 = [[UITableViewCell 分配]
initWithStyle:UITableViewCellStyleDefault
重用标识符:@“细胞”];
}
NSString *currentProductName;
currentProductName = [productKeys objectAtIndex:indexPath.row];
NSLog(@"产品名称:%@", currentProductName);
[[单元格文本标签] setText:currentProductName];
返回单元格;
}
它返回 0 行,我是 ios 的新手,请帮助我如何将这些值分配给 uitableview。
问候