带有sigbart错误的NSexception

时间:2016-10-18 11:13:56

标签: ios objective-c json web-services

我正在尝试从json Web服务获取结果。对于字符串值,它工作正常。当我尝试获取整数值时,它会抛出带有sigbart错误的nsexeption。

我的json结果像这样松散。

[{"CaseId":81,"ApplicantName":"test","ApplicantContactNo":"teas","PropertyAddress":"ewae","BankName":"Bank of India","ReportDispatcher":null,"PropertyType":"test","AssignedAt":"2016-10-07T13:01:20","Status":"Open","PropertyId":62,"EmployeeName":null,"StatusId":1}

当我尝试捕获CaseId和AssignedAt时,它会抛出错误。

这是我的代码。

NSString * caseid = @"CaseId";
NSString * assigned = @"AssignedAt";
for (NSDictionary *dataDict in jsonObjects) {
    NSString *caseid1 = [dataDict objectForKey:@"CaseId"];
    NSString *assigned1 = [dataDict objectForKey:@"AssignedAt"];
    dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
                  caseid1,caseid,assigned1,assigned, nil];                      
    [myObject addObject:dictionary];
}
cell.caseid.text=[tmpDict objectForKey:@"CaseId"];
cell.days.text=[tmpDict objectForKey:@"AssignedAt"];

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

这应该适合你:

NSString *caseIdValue = [NSString stringWithFormat:@"%@",[dataDict objectForKey:@"CaseId"]];
NSString *assignedAtValue = [NSString stringWithFormat:@"%@",[dataDict objectForKey:@"AssignedAt"]];