I'm starting Objective-C (from Python)
I need to create and initialize a simple dictionary.
In Python, I'm used to:
arr = [
{'fieldX': value1, 'fieldY': value2},
{'fieldX': value3, 'fieldY': value3},
]
Here is what I do in Objective-C
NSArray *arr = [NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
value1, @"fieldX", value2, @"fieldY"
, nil]
, [NSDictionary dictionaryWithObjectsAndKeys:
value3, @"fieldX", value4, @"fieldY"
, nil]
, nil
];
Is there an easier way to initialize this array of dictionaries?
source
share