Q:

How to parse a JSON dictionary and put the keys and values in separate arrays - Objective C

I'm trying to parse www.fixer.io JSON to get currency data. I've been having trouble parsing the JSON and trying to separate the keys and values from the "rates" dictionary. I need them separate so I can put them in arrays to display the currency name (ex: USD, EUR, JPN) and their respective rates.
I've read that I have to use the "allKeys" and "allValues" to do this but so far I'm having no luck. Any ideas?
NSURL *fixerURL = [NSURL URLWithString:@"http://api.fixer.io/latest?base=USD"];
NSData *data = [NSData dataWithContentsOfURL:fixerURL];
NSError *error;

    NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];

    NSMutableArray *arr = [[NSMutableArray alloc]init];
    NSMutableArray *arr2 = [[NSMutableArray alloc]init];
    NSArray *names;
    NSArray *rates;

    for (names in json) {
        names = [json allKeys];
        for (rates in json) {
            rates = [json allValues];
        }
        [arr addObject:names];
        [arr2 addObject:rates];
    }
    self.currencyList = arr;
    self.currencyRates = arr2;
    [self updateTableView];

Here is the JSON ---> http://api.fixer.io/latest?base=USD

A:

Hope this will help you,
NSURL *fixerURL = [NSURL URLWithString:@"http://api.fixer.io/latest?base=USD"];
    NSData *data1 = [NSData dataWithContentsOfURL:fixerURL];
    NSError *error;

    NSDictionary *json1 = [NSJSONSerialization JSONObjectWithData:data1 options:kNilOptions error:&error];
    NSLog(@"%@",json1);
    NSDictionary *json = [[NSDictionary alloc]initWithDictionary:[json1 objectForKey:@"rates"]];
    NSMutableArray *arr = [[NSMutableArray alloc] initWithArray:[json allKeys]];
    NSMutableArray *arr2 = [[NSMutableArray alloc]initWithArray:[json allValues]];
    NSLog(@"%@",arr);
    NSLog(@"%@",arr2);

