1

I got this json response and i created an object for nsdictionary and saved there as

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

and next step i saved as an array

NSArray *country=[json objectForKey:@"results"];

And then i got the following result in my console.

2012-06-18 09:22:07.647 TableView[468:f803] (
                {
                "Countries" = Iceland;
                 "id"=9046567;
                  "name"=abceeeffdsg;


            },
                {
                "Countries" = Greenland;
                "id"=3524695;
                "name"=gsfjgfsethju;
    },
                {
                 "Countries" = Switzerland;
                 "id"=4613583;
                 "name"=hdfkdgs;
        )

But actually i want to display these data in a UITableView. Can anyone help me make my work completed.... thanks for your kindness...

1 Answer 1

0

In the tableview datasource methods

1. numberof RowInSection use the [country count];
2. In the cellForRowAtIndexPath

    cell.textLabel.text = [[country objectAtIndex:indexPath.row] objectForKey:@"Countries"];

Let me know if you need any more details.

4
  • ohh thanks but this is not i wanted. can u read the question again i have no trouble in adding rows and row counts to my UITableView. Actually i am not able to get the datas from the json array to my table... and this is not the code for that. can u help me rather than giving -ve marks....
    – goku
    Sep 26, 2012 at 5:12
  • NSArray *a = [country valueForKey:@"Countries"];
    – SRI
    Sep 26, 2012 at 9:11
  • thank u.... another doubt... i cant access this array outside the " -(void)fetchedData:(NSData *)responseData" can u help me in this..
    – goku
    Sep 26, 2012 at 9:39
  • 1
    In .h file declare that array, alloc memory in viewdidload and access any where.
    – SRI
    Sep 26, 2012 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.