Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8662339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:42:55+00:00 2026-06-12T16:42:55+00:00

I am new in objective-c and working on ios app where i am parsing

  • 0

I am new in objective-c and working on ios app where i am parsing json array and displaying it in table cell. I have the problem that i want to display 2 json array values in single cell but i am not getting the values properly, here is my json array

    {
    "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";
}

here i want to show the fighter name from two diffrent arrays in sigle cell, eg. kaushik sen vs kultar singh gill, but i am getting alternate player names in cells. here is my objective c code.

- (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];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:42:56+00:00Added an answer on June 12, 2026 at 4:42 pm

    The problem is when you are writing the names to the cell.
    For each row, you are getting the current row, and the current row + 1.

    So imagine you have fighters

    0. John
    1. Bob
    2. Bill
    3. Carl
    4. Tom
    5. Mark
    

    Since the tableView:cellForRowAtIndexPath: asks you to configure every row, what you are displaying is this:

    Row 0: display 0 and 1 (John vs Bob)
    Row 1: display 1 and 2 (Bob vs Bill)
    Row 2: display 2 and 3 (Bill vs Carl)
    

    What you need to do is change the way you get your fighters out.
    Instead of displaying the fighters at the (current row) and (current row + 1), you need to be displaying 2*(current row) and (2*currentRow + 1)

    Row 0: 0 and 1 (John vs Bob)
    Row 1: 2 and 3 (Bill vs Carl)
    Row 2: 4 and 5 (Tom vs Mark)
    

    So, to fix your code by adding 4 characters:

    cell.lblPlayer1.text =  [arrayOfFighterName objectAtIndex:2*indexPath.row];
    cell.lblPlayer2.text =  [arrayOfFighterName objectAtIndex:2*indexPath.row +1];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to iOS and Objective-C. I have an application that displays a table
I have an iOS app in the app store. I'm working on some new
I'm new to objective C and currently working on a small project. I have
I'm new to Objective-C and I have been working with simple programs, and I
As you can tell, I'm new to Objective-C. I currently have a Singleton working,
I'm working on an iOS app and have had some trouble with getting photos
fairly new to Objective-C and iOS development (coming from PHP) and I have a
I am new to iOS Development and Objective-C in general. Currently I am working
I'm pretty new to Objective C and iPhone development and have hit a problem
I'm working on my first somewhat serious iOS app and I'm new to Xcode,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.