안녕하세요 저는이 이미지와 같은 2 차원 배열을 표시하려고하지만 코드가 작동하지 않습니다. 제 json respone이 UITableView에 표시하려는 이미지에 있습니다.
-(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;
}
도움이되기를 바랍니다.
당신은 약간의 실수를하고 있습니다.
arrayCategories = [responseObj valueForKey:@"categories"]; //Which is already there in your code....
그리고 textLabel에서 값을 가져 오는 동안 다음과 같이 작성하십시오.
cell.textLabel.text = [[[arrayCategories objectAtIndex:indexPath.row] componentsSeparatedByString:@"="] objectAtIndex:1];
여기에 valueForKey "categories"를 쓰지 마십시오. 여전히 문제가 있으면 알려주세요.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다