我有这样的JSON对象。
{
"id": "1",
"subTotal": "20000.00",
"total": "124565.00",
"timeOfTrans": "3555525",
"status": "1",
"name": "gjgjgf",
"email": "a@a.com",
"level": "gjfgj",
"teamId": "1"
},
{
"id": "2",
"subTotal": null,
"total": null,
"timeOfTrans": null,
"status": null,
"name": "Rajendra",
"email": "b@b.com",
"level": "gfjgfjg",
"teamId": "1"
}
我想在标签中显示JSON字符串“total”。当“总计”为空时,我想在“总计”是某个数字时显示“0”,我想在同一标签中显示该数字。
我在这里尝试这段代码
totalLbl=(UILabel *)[cell viewWithTag:1];
id total = [currentEmplyCellDit objectForKey:@"total"];
if ([total isKindOfClass:(id)[NSNull null]])
{
//Your value of total is NULL
totalLbl.text = @"0";
}
//Show the Value.
totalLbl.text = [NSString stringWithFormat:@"%@",total];
此代码正确显示,但当“总计”为空时,我在标签中显示空。
当“total”为 NULL 时,我想显示 0
如何解决这个...谢谢。