我JSON對象是這樣的。如何顯示在標籤的字符串值,如果值是零和若干
{
"id": "1",
"subTotal": "20000.00",
"total": "124565.00",
"timeOfTrans": "3555525",
"status": "1",
"name": "gjgjgf",
"email": "[email protected]",
"level": "gjfgj",
"teamId": "1"
},
{
"id": "2",
"subTotal": null,
"total": null,
"timeOfTrans": null,
"status": null,
"name": "Rajendra",
"email": "[email protected]",
"level": "gfjgfjg",
"teamId": "1"
}
我想在標籤中顯示JSON字符串 「總」。當「總數」爲空時,我想顯示'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];
驗證碼正確顯示,但我顯示空的標籤時,「總」爲空。
我想顯示0時, 「總」 是NULL
如何解決這個... 感謝。
檢查我更新的答案哥們。 – Rajneesh071