【发布时间】:2017-10-26 02:59:05
【问题描述】:
我正在使用 Objective-c 开发一个简单的 IOS 应用程序,我想将图像加载到表格单元格中。 我有一个小网络服务,它给我一个像这样的 json 数据:
[{"id":1,"name":"Papas","description":"Papas chilotas negras","images":
[{"url":"/uploads/product/images/1/8282486574_382f59c31e_o.jpg",
"thumb":"url":"/uploads/product/images/1/
thumb_8282486574_382f59c31e_o.jpg"},
"catalog":"url":"/uploads/product/images/1/
catalog_8282486574_382f59c31e_o.jpg"},
"big":"url":"/uploads/product/images/1/
big_8282486574_382f59c31e_o.jpg"}}],
"price":1200,"stand_id":3,"created_at":"2017-10-
24T04:01:09.000Z","updated_at":"2017-10-24T04:01:09.000Z"}]
我已经设置了这样的名称和描述tableCell
问题是我如何访问拇指版本图像的路径以将其显示在表格单元格中。
这是我必须填充表格的代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
NSDictionary *dictionary = [self.json objectAtIndex:indexPath.row];
cell.textLabel.text=[dictionary objectForKey:@"name"];
cell.detailTextLabel.text = [dictionary objectForKey:@"description"];
return cell;
}
【问题讨论】:
-
这是一个有效的 JSON 吗?
-
URL 无效 ->
"thumb" : "url" : " /uploads/product/... /_o.jpg" -
json 数据来自这个 url 18.221.78.126/ecoferia/api/products 它来自一个带有 mysql db 的 Rails 应用程序。
标签: ios objective-c json tableview