title: Get data from JSON to table view
body: <p>I have a JSON data from <a href="http://vmg.hdvietpro.com/ztv/home" rel="nofollow">http://vmg.hdvietpro.com/ztv/home</a> . I want to get text1,thumbnailImage value in this JSON after clicking getData button to get text1,thumbnailImage(NSString) values from JSON to table view. This is my code and after click button nothing happen. Thanks for help.</p>
  
  <pre><code>@interface ViewController ()
  {
      NSMutableData *webData;
      NSURLConnection *connection;
      NSMutableArray *moviesArray;
  
  }
  @end
  
  @implementation ViewController
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view, typically from a nib.
      [[self myTableView]setDelegate:self];
       [[self myTableView]setDataSource:self];
      moviesArray=[[NSMutableArray alloc]init];
  }
  
  - (void)didReceiveMemoryWarning
  {
      [super didReceiveMemoryWarning];
      // Dispose of any resources that can be recreated.
  }
  -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
      [webData setLength:0];
  }
  -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
      [webData appendData:data];
  }
  -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
      NSLog(@"Fail");
  }
  -(void)connectionDidFinishLoading:(NSURLConnection *)connection{
      NSDictionary *allDataDictionary=[NSJSONSerialization JSONObjectWithData:webData options:0 error:nil];
      NSDictionary *response=[allDataDictionary objectForKey:@"response"];
      NSDictionary *hotProgram=[response objectForKey:@"hot_program"];
                                   NSArray *itemPageHot=[hotProgram objectForKey:@"page"];
      for (NSDictionary*dic  in itemPageHot) {
          NSString *text1=[dic objectForKey:@"text1"];
          [moviesArray addObject:text1];
  
  
      }
      [[self myTableView]reloadData];
  }
  - (IBAction)getData:(id)sender {
      NSURL *url=[NSURL URLWithString:@"http://vmg.hdvietpro.com/ztv/home"];
      NSURLRequest *request=[NSURLRequest requestWithURL:url];
      connection = [NSURLConnection connectionWithRequest:request delegate:self];
      if(connection){
          webData =[[NSMutableData alloc]init];
          NSLog(@"ket noi thanh cong");
      }
  }
  -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
      return [moviesArray count];
  }
  -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
      return 1;
  }
  -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
      static NSString*CellIndentifier=@"Cell";
      UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIndentifier];
  
      if(!cell){
          cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIndentifier];
      }
      cell.textLabel.text=[moviesArray objectAtIndex:indexPath.row];
      return cell;
  }
  </code></pre>