NSDictionary with ordered keys
The solution of having an associated NSMutableArray of keys isn’t so bad. It avoids subclassing NSDictionary, and if you are careful with writing accessors, it shouldn’t be too hard to keep synchronised.
The solution of having an associated NSMutableArray of keys isn’t so bad. It avoids subclassing NSDictionary, and if you are careful with writing accessors, it shouldn’t be too hard to keep synchronised.
Your root json object is not a dictionary but an array: [{“id”: “1”, “name”:”Aaa”}, {“id”: “2”, “name”:”Bbb”}] This might give you a clear picture of how to handle it: NSError *e = nil; NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData: data options: NSJSONReadingMutableContainers error: &e]; if (!jsonArray) { NSLog(@”Error parsing JSON: %@”, e); } else { for(NSDictionary … Read more