How to create NSDictionary in Objective-C?

I want to create an NSDictionary like this type:

"zones": 
{
    {
        "zoneId": "1",
        "locations": 
        {
            {
                "locId": "1",
                "locZoneId": "1",
                "locLatitude": "33.68506785633641",
                "locLongitude": "72.97488212585449"
            },
            {
                "locId": "2",
                "locZoneId": "1",
                "locLatitude": "33.68506785633641",
                "locLongitude": "72.97488212585449"
            },
            {
                "locId": "3",
                "locZoneId": "1",
                "locLatitude": "33.68506785633641",
                "locLongitude": "72.97488212585449"
            },
        }
    }
}

But I do not know how to create.

+4
source share
1 answer

You should use a combination of arrays and dictionaries.

Dictionaries are initialized as follows:

NSDictionary *dict = @{ key : value, key2 : value2};

Arrays are initialized as follows:

NSArray *array = @[Object1, Object2]
+19
source

Source: https://habr.com/ru/post/1667836/


All Articles