1 year ago

#162532

test-img

Microcad

Iteract through __NSSingleObjectArrayI in Objective-C

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
        }
    ]
}

objective-c

nsarray

nsdictionary

0 Answers

Your Answer

Accepted video resources