Array does not receive data for a particular key

advertisements

Response array like this

 NewDataSet =     {
        Table =         (
                        {
                City =             {
                    text = "\nThiruvananthapuram";
                };
                Country =             {
                    text = "\n\nIndia";
                };
                text = "\n";
            },
                    {
                City =             {
                    text = "\nVellore";
                };
                Country =             {
                    text = "\n\nIndia";
                };
                text = "\n";
            }
        );
        text = "\n";

I have write this code..

xmlDictionary = [XMLReader dictionaryForXMLString:xmlResultString error:nil];

    NSLog(@"%@",xmlDictionary);

    NSLog(@"%@",xmlDictionary);

    NSArray * responseArr = xmlDictionary[@"NewDataSet"];

    NSLog(@"%@",responseArr);

    for(NSDictionary * dic in responseArr)
    {
        NSLog(@"%@",dic);

        //[array1 addObject:[dic valueForKey:@"City"]];

        [array1 addObject:[[dic valueForKey:@"City"] valueForKey:@"text"]];

    }

but not get the data. in array1. please help me out this thanks in advance.

Problem is i will not get the value in NSDictionary.

Error log is

this class is not key value coding-compliant for the key City.'


I got my Solution problem is i will not get the direct City key. Because City key is under the NewDataSet & Table

so first you go to the NewDataSet and then Table key then finally you get the City key.

Now get array data from Dictionary Like

NSArray * City=[[NSArray alloc]init];

City=[[[xmlDictionary valueForKey:@"NewDataSet"] valueForKey:@"Table"] valueForKey:@"City"];

NSLog(@"%@",City);

pass multiple keys inside key this is the solution.