I'm getting the below response and how do I iterate or get the values?
<__NSSingleObjectArrayI 0x600002edeea0>(
{
link = "<null>";
ValueG = "%";
ValueT = 1;
ValueV = "5.00";
ValueS = "%";
ValueGTX = 1;
ValueGT = "5.00";
ValueZH = 1;
time = 30;
UG = “test”;
ValueSFS = "%";
ValueFT = 1;
ValueSFV = "5.00";
SID = “000”;
SN = Test;
ST = "";
ValueTV = "10.00";
"__type" = “WSDInfo”;
}
)
This is how I tried to get the value, but it is throwing the following error Expected method to read array element not found on object of type 'NSDictionary *'
self.valuesInfo = [MTLJSONAdapter modelOfClass:self.valueType.storeInfoClass
fromJSONDictionary:JSON
error:NULL];
NSDictionary *storeInfoDict = JSON;
if (storeInfoDict.count != 0) {
for (int i=0; i <= storeInfoDict.count; i++){
NSString *ValueG = storeInfoDict[i][@"ValueG"];
}
}
Below is the response from postman. In the code, "d" is removed by the JSONResponseSerializer
{
"d": [
{
"__type": "WSDInfo",
"SID": “000”,
“SN”: “Test”,
“ST”: "",
"UG": “Test”,
"time": "30",
"ValueTV": "10.00",
"ValueG": "%",
"ValueV": "5.00",
"ValueT": "1",
"ValueSFS": "%",
"ValueGT": "5.00",
"ValueGTX": "1",
"ValueS": "%",
"ValueSFV": "5.00",
"ValueZH": "1",
"ValueFT": true,
"link": null
}
]
}
storeInfoDictdeclared?NSArray(optimized for handling Single objects), but treat it as aNSArrayinstance. Inside there is aNSDictionary. But I guess, by the name and the error thatstoreInfoDictis declared as aNSDictionary. Well, it has only the name of it, because as saiid, it's in fact aNSArray.NSDictionarybut the value at the end of the pointer is not aNSDictionary, it's aNSArray. Why? How did you get that value?NSDictionary, you are enumerating like it was aNSArray. Look how to enumerate aNSDictionaryfirst. Then, the value will be aNSArray, enumerate it too, and then acsess the valueG.