我试图在UITableViewcell中显示may json响应的详细列表

时间:2015-12-03 11:54:32

标签: ios objective-c json uitableview

您好我试图在第二个表格视图中显示json数据的详细信息,但是我的逻辑中有一些错误所以请帮助我,我的json响应是在图像中,我试图在用户表格视图中显示通道响应点击相同的cat_id然后在第二个tableViewcell中显示所有相关的频道列表和图片请帮帮我.. enter image description here

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

        NSString *str=@"http://streamtvbox.com/site/api/matrix/";//?country_code=91&phone=9173140993&fingerprint=2222222222";
        NSString *method=@"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];




}

1 个答案:

答案 0 :(得分:0)

只需初始化您的NSmutuableArray并添加addobject的值,如: -

#!/bin/bash

# Download latest example of a database (updated automatically and periodically)
wget -mirror "http://somedatabase/database_latest

# Run a command that generates an output for a set of files queried against the latest database)
for file in /some/dir/*;
do
    command -output $file.txt -database database_latest
done

# Now for the bit I'm more interested in.
# If the database has been updated, the 'output.txt' 
# for each file will be different.
# So, using diff...:

if [ diff $file.txt $file_old.txt == 1 ] # where file_old.txt is 
                                         # the output of the command the 
                                         # last time it ran for that file.
    then
        mv $file_old ./archive/ # Keep the old file but stash it in a separate dir
    else
        break
fi

 # Make some report file from all of the outputs
 cat *.txt > report.txt

}