- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:@"myCell"];
if (cell == nil)
{
[tableView registerNib:[UINib nibWithNibName:@"CustomCell" bundle:nil] forCellReuseIdentifier:@"myCell"];
cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:@"myCell"];
}
if (cell.tag == 0)
{
}
str = [jsonData objectAtIndex:cell.tag];
NSDictionary *dict = [jsonData objectAtIndex:indexPath.row];
cell.lblDeliveryTime.text = [dict valueForKey:@"sysord_ExpectedDeliveryTime"];
cell.lblOrderPlacedTime.text = [dict valueForKey:@"sysord_OrderDateTime"];
cell.lblDeliveryPickUP.text = [dict valueForKey:@"sysord_DeliveryType"];
NSDictionary *dict1 = [jsonData objectAtIndex:cell.tag];
orderidString = [dict1 valueForKey:@"sysord_ID"];
DetailViewController *detailVC=[[DetailViewController alloc]initWithNibName:@"DetailViewController" bundle:nil];
return cell;
}
答案 0 :(得分:3)
其中一个值不是NSString
,而是NSNumber
。
我建议你先检查一下类型,但是如果你想要总是转换为字符串,你可以使用:
cell.lblDeliveryPickUP.text = [NSString stringWithFormat:@"%@", dict[@"sysord_DeliveryType"]];
答案 1 :(得分:2)
当您将字典中的对象分配给text
时,您需要确保它是NSString类型。
cell.lblDeliveryTime.text = [[dict objectForKey:@"sysord_ExpectedDeliveryTime"] stringValue];
cell.lblOrderPlacedTime.text = [[dict objectForKey:@"sysord_OrderDateTime"] stringValue];
cell.lblDeliveryPickUP.text = [[dict objectForKey:@"sysord_DeliveryType"] stringValue];