나는 객관적인 -c로 새롭고 json 배열을 파싱하고 테이블 셀에 표시하는 ios 응용 프로그램에서 작업합니다. 나는 하나의 셀에 2 JSON 배열 값을 표시 할 문제가있다하지만 난 제대로 값을 받고 있지 않다, 여기 여기objective-c의 단일 테이블 셀에 두 개의 json 배열 값을 표시하는 방법
{
"event_id" = 7;
"fighter_id" = 26;
"fighters_name" = "Kaushik Sen";
"fighters_photo" = "Kaushik.jpg";
"match_id" = 28;
"match_type" = Bantamweight;
"profile_link" = "link";
}
{
"event_id" = 7;
"fighter_id" = 21;
"fighters_name" = "Kultar Singh Gill";
"fighters_photo" = "Kultar.jpg";
"match_id" = 27;
"match_type" = "Welterweights Main Event";
"profile_link" = "link";
}
내가 두 diffrent 배열에서 전투기 이름을 표시 할 내 JSON 배열입니다 sigle 세포, 예. kaushik sen 대 kultar singh 아가미하지만 셀에 대체 플레이어 이름이 나타납니다. 여기에 나의 객관적인 C 코드가있다.
- (void)viewDidLoad
{
[super viewDidLoad];
[self MatchList];
}
-(void)MatchList {
NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://example.com/appleapp/eventDetails.php"]];
NSError *error;
//code to execute php code
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error];
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSMutableArray *matchListArray = [[NSMutableArray alloc]init];
matchListArray = [json objectForKey:@"products"];
arrayOfFighterName=[[NSMutableArray alloc] init];
arrOfMatchId = [[NSMutableArray alloc] init];
for(int i = 0; i<[matchListArray count]; i++){
// NSLog(@"%@", [matchListArray objectAtIndex:i]);
arrayOfFighterName[i]=[[matchListArray objectAtIndex:i] objectForKey:@"fighters_name"];
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [arrayOfFighterName count]/2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
cell = (MyFighterCell *)[tableview dequeueReusableCellWithIdentifier:kCellIdentifier];
select = indexPath.row;
if(cell == nil){
cell = [[[MyFighterCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellIdentifier] autorelease];
[cellOwner loadMyNibFile:kCellIdentifier];
cell = (MyFighterCell *)cellOwner.cell;
}
cell.lblPlayer1.text = [arrayOfFighterName objectAtIndex:indexPath.row];
cell.lblPlayer2.text = [arrayOfFighterName objectAtIndex:indexPath.row +1];
}