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 9159575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:31:36+00:00 2026-06-17T13:31:36+00:00

I’m using a website API to populate my tableViews, using Restkit and JSON for

  • 0

I’m using a website API to populate my tableViews, using Restkit and JSON for request/receive/parse data into my model. Already set up models and mapping which seem to be working fine.

The problem is after the initial table view that loads Section & Row, I need the second tableView to use the cell/row selected from the tableView, to show the team associated with that specific League that was chosen in the second tableView.

I believe it’s the …

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
  • (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

that I don’t have or have correct, because it’s:

Populating data correctly in initial screen:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return sports.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    Sport *sport = [sports objectAtIndex:section];
    return sport.leagues.count;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 
{
    Sport *sport = [sports objectAtIndex:section];
    return sport.name;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"standardCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    Sport *sport = [sports objectAtIndex:indexPath.section];
    League *league = [sport.leagues objectAtIndex:indexPath.row];
    cell.textLabel.text = league.name;

    return cell;
}

But if I select a cell, the second ViewController is a blank tableView (note: no prepareForSegue or didSelectRowAtIndexPath code in previous ViewController tableView code, so I think thats why I might be getting this blank tableview):

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return leagues.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    League *league  = [leagues objectAtIndex:section];
    return league.teams.count;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 
{
    League *league = [leagues objectAtIndex:section];
    return league.name;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"standardCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    League *league = [leagues objectAtIndex:indexPath.section];
    Team *team = [league.teams objectAtIndex:indexPath.row];
    cell.textLabel.text = team.name;

    return cell;
}

Or if I add prepareForSegue and didSelectRowAtIndexPath code in previous ViewController, select a cell which would move us to the next ViewController, the app crashes (prepareForSegue and didSelectRowAtIndexPath code aren’t correct for sure, I was trying to just piece something together even though I did at least some of it is wrong):

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    TeamsViewController *teamsViewController = [[TeamsViewController alloc] initWithNibName:@"TeamsViewController" bundle:nil];
    teamsViewController.title = [[sports objectAtIndex:indexPath.row] objectForKey:@"sports"];

}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"leagueDetail"]) {
        TeamsViewController *tvc = [segue destinationViewController];
        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        tvc.data = [self.navigationController objectInListAtIndex:indexPath.row]
}

I think what I’m running into is needing for the selected cell to pass its info to the next tableView somehow, and I don’t know if it needs to somehow append that info to the baseURL I’m retrieving the data from for that selected row, and then also somehow show the data in the teams tableView. But I’m not sure if thats the problem, and/or how exactly to implement it.

Would appreciate any help, and just let me know if more code/details are needed, I’d be happy to get them quickly for anyone.

EDIT: Here is my updated prepareForSegue code, still have error though-
Error: Property ‘leagues’ not found on object of type ‘TeamsViewController’

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"leagueDetail"]) {

        // note that "sender" will be the tableView cell that was selected
        UITableViewCell *cell = (UITableViewCell*)sender;
        NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];

        TeamsViewController *tvc = (TeamsViewController *)[segue destinationViewController];
        tvc.leagues = [leagues objectAtIndex:indexPath.section];
    }
}
  • 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-17T13:31:37+00:00Added an answer on June 17, 2026 at 1:31 pm

    You need to link your Prototype Row in storyboard with the next view controller, name the segue and use prepareForSegue to pass the necessary data. No need for didSelectRow....

    To reference the row, use

    [self.tableView indexPathForCell:(UITableViewCell*)sender]
    

    (I would not rely on the selected state of the row. You would be mixing View and Model domains, violating MVC principles.)

    Also, I noticed a certain logic mistake. If in VC2 you want to show leagues as the sections and teams on the table view rows, you should really be selecting a Sport not a league. A league does not have many leagues, right?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using jsonparser to parse data and images obtained from json response. When
I am using JSon response to parse title,date content and thumbnail images and place
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I have a French site that I want to parse, but am running into
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am confused How to use looping for Json response Array in another Array.

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.