ios - 无法在 uitableview 中解析 json 文件

标签 ios json uitableview ios7

嗨, friend 们,我在将 json 文件解析为 uitableview 时遇到了问题。 我的 json 文件如下所示:

[
    {
    "id": 1,
    "type": "Deal Closed",
    "score": 100,
    "createdAt": "2014-10-03T08:10:10.000Z",
    "updatedAt": "2014-10-03T08:10:10.000Z"
    },
    {
    "id": 2,
    "type": "Followers",
    "score": 10,
    "createdAt": "2014-10-03T08:10:28.000Z",
    "updatedAt": "2014-10-03T08:10:28.000Z"
    }
]

我的代码在这里..

static NSString *CellIdentifier = @"Leader";    
NSString *firstname = [[promoArray objectAtIndex:indexPath.row] objectForKey:@"type"];
NSString *lastname = [[promoArray objectAtIndex:indexPath.row] objectForKey:@"score"];
cell.lblPrice.text=[jsonDict valueForKey:@"type"];
cell.lblDesc.text=[jsonDict valueForKey:@"score"];

它在解析时抛出异常。我需要将类型和分数从 json 文件解析到 Uitable View 。

最佳答案

对此进行调整:

cell.lblPrice.text=jsonDict[indexPath.row][@"type"];
cell.lblDesc.text= jsonDict[indexPath.row][@"score"];

关于ios - 无法在 uitableview 中解析 json 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26180575/

相关文章:

iphone - while循环内存问题

ios - 如何在 ios 5 中以编程方式删除特定组的联系人?

ios - 检测首次启动时出错(Swift)

javascript - 如何使用数据属性提取数据?

c# - 访问 JToken 的值时出现异常 - 无法访问 Newtonsoft.Json.Linq.JValue 上的子值

ios - 带有自定义 UITableViewCells 的表单

ios - UIActivityViewController 无法共享图像

python - 如何 JSON 序列化对象并包含 @property 属性,同时排除函数?

ios - 获取核心数据中具有关系的实体

ios - 如何将 uitableview 中的单个单元格链接到不同的 URL?