【发布时间】:2015-12-02 07:55:30
【问题描述】:
您好,我正在尝试显示此图像中的响应,但未显示,并且出现了一些错误,请帮助我
-(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;
}
【问题讨论】:
-
您何时何地调用方法“getCategories”?我不确定,但看起来你应该在“getCategories”方法的末尾重新加载 tableView。
-
responseObj是数组还是字典? -
@Birendra 请提供更多详细信息,关于响应结构,但这里缺少 reload tableview
-
在 responseObj 中,“类别”键在哪里?
标签: ios objective-c json uitableview