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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:30:28+00:00 2026-06-13T01:30:28+00:00

I have a UITableView that pushes, via a storyboard segue, a view, which displays

  • 0

I have a UITableView that pushes, via a storyboard segue, a view, which displays a UILabel that I wish to change the text on relative to the indexPath.row of the selected accessory on the UITableView.

I know it’s probably wildly wrong, but this was my attempt. I feel like I’m going about it very wrong:

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier:@"ArticlePreviewSegue" sender:self];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    NSIndexPath *indexPath = [sender indexPathForSelectedRow];
    ArticlePreviewViewController *apvc = [segue destinationViewController];
    NSDictionary *article = [_newsFetcher.articles objectAtIndex:indexPath.row];
    apvc.titleLabel.text = [article objectForKey:@"title"];
    apvc.bodyLabel.text = [article objectForKey:@"body"];
}

Thanks you!

  • 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-13T01:30:29+00:00Added an answer on June 13, 2026 at 1:30 am

    One problem may be that tapping the accessory doesn’t select the row. You can handle that by passing the index path as the sender of the segue:

    - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
        [self performSegueWithIdentifier:@"ArticlePreviewSegue" sender:indexPath];
    }
    

    Now you can access the index path in prepareForSegue:sender: without relying on the row being selected.

    Another problem is that in prepareForSegue:sender:, apvc hasn’t loaded its view yet. So apvc.titleLabel and apvc.bodyLabel are both nil.

    The proper way to handle this is to give ArticlePreviewViewController an article property and set that property in prepareForSegue:sender:, like this:

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        NSIndexPath *indexPath = (NSIndexPath *)sender;
        ArticlePreviewViewController *apvc = [segue destinationViewController];
        apvc.article = [_newsFetcher.articles objectAtIndex:indexPath.row];
    }
    

    Then, in -[ArticlePreviewViewController viewDidLoad], you can set the labels based on the article:

    - (void)viewDidLoad {
        [super viewDidLoad];
        self.titleLabel.text = self.article[@"title"];
        self.bodyLabel.text = self.article[@"body"];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableView that displays single large images in each cell. The names
I have a UITableView that displays various nsstrings from a custom object called a
I have a UITableView that displays some data that is read in at runtime
I'm using storyboards and I have a UITableView. I have a segue setup that
I have a UITableView on a view. This UITableView has cells which are made
I have a Nav controller that starts at a table view. Each row pushes
I have a RootViewController that is a UIViewController with a UITableView. This RootViewController pushes
I have a view controller that contains a UITableView. When the view controller gets
I have a project: first view is uitableview, when you select row uinavigationcontroller pushes
I have a UITableView that lists comments from various users. I save all of

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.