How can I read an Array that contains objects in this format:
Second pair: {
latitude = "26.499023";
longitude = "42.326061";
}
??
EDIT:
NO..this is the way I come up with that...
NSArray *MaparrayLongitude = [dataMap objectForKey:@"longitude"];
NSArray *MaparrayLatitude = [dataMap objectForKey:@"latitude"];
if (MaparrayLongitude.count != MaparrayLatitude.count) {
//Error: Unequal number of longitude/latitude values
} else {
NSMutableArray *pairs = [NSMutableArray array];
for (int i = 0; i < MaparrayLongitude.count; i++) {
NSDictionary *pair = [NSDictionary dictionaryWithObjectsAndKeys:
[MaparrayLongitude objectAtIndex:i], @"longitude",
[MaparrayLatitude objectAtIndex:i], @"latitude", nil];
[pairs addObject:pair];
The answer that I suspect you are looking for is called NSDictionary.
I came from PHP where we called it an array if it was either numerically indexed or keyed with strings; in Objective-C, there are 3 basic kinds of collections:
NSArray – ordered, natural integers as indexes
NSSet – unordered collection, single-membership
NSDictionary – keyed on one of several kinds of objects, usually strings.
Here is apple’s docs
Edit: for reference, here is what your code might end up looking like:
EDIT (after your edit):
Perhaps it’s fast enumeration, in conjunction with dictionary access that you seek: