2015-12-02 107 views
0

enter image description here我想顯示的UITableViewCell JSON的響應,但沒有工作

嗨,我想這樣的圖像中顯示的反應,但不顯示,有些錯誤是發生所以請幫我

-(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) 
    { 
     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; 
} 
+0

何時何地稱爲方法「getCategories」? 我不確定,但看起來像你應該在「getCategories」方法的末尾重新加載tableView。 – Oleshko

+0

'responseObj'是一個數組或字典? – anhtu

+0

@Birendra請給出更多的細節,關於響應結構,但在這裏重新加載tableview丟失 – satheesh

回答

0

收到回覆後請重新加載,

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

嗨,但它給出了一個錯誤 – Birendra

+0

[__NSCFDictionary objectAtIndex:]:無法識別的選擇器發送到實例 – Birendra

+0

顯然你的arrayCategories對象不是一個數組,但是一個字典 - 但你嘗試訪問它作爲數組ATLowForIndexPath函數... – TheEye