Q:

UITableView not loading JSON data

I am developing a app that will load remote data in a UITableView but when I run it, it shows nothing. Please view and help me to debug it. Thanks
Json outPut
{
    "emp_info" =     (
                (
            1,
            firstname_one,
            lastname_one,
            "abcd@xyz",
            "500 B3 abc Town"
        ),
                (
            2,
            firstname_two,
            lastname_two,
            "abcd@xyz",
            "500 B3 abc Town"
        ),
                (
            18,
            firstname_three,
            lastname_three,
            "abcd@xyz",
            "500 B3 abc Town"
        )
    );
}

And .m file
- (void)viewDidLoad
{
    [super viewDidLoad];

    statuses=[[NSMutableArray alloc]init];

    NSURL *myURL = [NSURL URLWithString:@"http://abcd.com/My_php/result.php"];

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:myURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60];

    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue]

                           completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {

                               NSLog(@"Finished with status code: %i", [(NSHTTPURLResponse *)response statusCode]);
                               id jsonObject = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];

                               NSLog(@"jsonObject=%@",jsonObject);

                               statuses=[jsonObject mutableCopy];

                               [self.theTableView reloadData];
                           }];

    NSLog(@"myURL=%@",myURL);
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSLog(@"%d",[statuses count]);
    return [statuses count];

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ;
    }

    id obj = [statuses objectAtIndex:indexPath.row];
    cell.textLabel.text =[obj valueForKey:@"Title"];

    return cell;
}

And when I compile it. it shows nothing in the table infect doesn't even show the table itself.

A:

You should get NSArray contains NSArrays from NSDictionary from JSON:
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue]
                       completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) 
{

...

// This Array contains arrays 
   statuses=[jsonObject[@"emp_info"] mutableCopy];
   [self.theTableView reloadData];
}];

In cellForRowAtIndexPath, get value from this NSArray:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

  ...
  // this is an NSArray, not an NSDictionary:
  NSArray *obj = [statuses objectAtIndex:indexPath.row];
  cell.textLabel.text = obj[1]; // just my example
}

