我试图在UITableViewCell中显示json的响应但不起作用

时间:2015-12-02 07:55:31

标签: ios objective-c json uitableview

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)
    {
        NSLog(@"%@",responseObj);
        arrayCategories = [responseObj valueForKey:@"categories"];
     }];
 }


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    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]valueForKey:@"categories"];

     return cell;
}

1 个答案:

答案 0 :(得分:0)

收到回复后请重新加载,

 [srv postToURL:str withMethod:method andParams:dict completion:^(BOOL success, NSDictionary *responseObj)
    {
        NSLog(@"%@",responseObj);
        arrayCategories = [responseObj valueForKey:@"categories"];
    [youTableView reloadDate];
     }];