2015-12-03 2 views
-2

Привет Я пытаюсь отобразить подробную информацию о json-данных во втором представлении таблицы, но их некоторая ошибка в моей логике, поэтому, пожалуйста, помогите мне, мой ответ json на изображении и Я пытаюсь для Dispaly отклика канала в виде таблицы, когда пользователь нажимает то же cat_id затем отобразить все сопутствующий список каналов и изображение во втором tableViewcell, пожалуйста, помогите мне .. enter image description hereЯ пытаюсь отобразить подробный список may json response в UITableViewcell

-(void)getCategories 
    { 
     Service *srv=[[Service alloc]init]; 

     NSString *[email protected]"http://streamtvbox.com/site/api/matrix/";//?country_code=91&phone=9173140993&fingerprint=2222222222"; 
     NSString *[email protected]"channels"; 
     NSMutableDictionary *dict=[[NSMutableDictionary alloc]init]; 


     [srv postToURL:str withMethod:method andParams:dict completion:^(BOOL success, NSDictionary *responseObj) 

     { 
      NSDictionary *dict = [[NSDictionary alloc]initWithDictionary:[responseObj valueForKey:@"categories"]]; 

         arrayChannelList=[responseObj valueForKey:@"channels"]; 
         NSLog(@"Array : %@",channels); 

         for (NSDictionary *dict in arrayChannelList) 
         { 
          //NSArray *tempTitle = [[NSArray alloc]init]; 

          arrayCat_Id = [dict objectForKey:@"cat_id"]; 

         } 

      tempArray = [[NSArray alloc]init]; 
      tempArray = [dict allKeys]; 
      for(int i=0; i<tempArray.count; i++) 
      { 

       [arrayCategories addObject:[dict valueForKey:[tempArray objectAtIndex:i]]]; 
      } 
      NSLog(@"%@",arrayCategories); 
      [tblView reloadData]; 

     }]; 
    } 




    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
    { 
     NSLog(@"%lu",(unsigned long)[arrayCategories count]); 
     return arrayCategories.count; 
    } 

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

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; 

    if (cell == nil) { 

     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier]; 
    } 

    cell.textLabel.text = [arrayCategories objectAtIndex:indexPath.row]; 


    return cell; 
} 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 

    DetailChannelsViewController *detailVC = (DetailChannelsViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"DetailView"]; 

    detailVC.channelTitle = [arrayCategories objectAtIndex:indexPath.row]; 
    detailVC.SubChannelName = arrayCat_Id; 

    NSLog(@"%@",arrayCat_Id); 

    [self.navigationController pushViewController:detailVC animated:YES]; 




} 
+0

arrayCat_Id - это Nsmutuable Array? –

+0

Привет, да, вы их? – Birendra

ответ

0

Просто инициализацию вашего NSmutuableArray и добавить значение с добавлением:

arrayCat_Id=[[NSMutableArray alloc]init]; 

for(your logic){ 
    [arrayCat_Id addobject:[dict objectForKey:@"cat_id"]; 

}

Смежные вопросы