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

  • Home
  • SEARCH
  • 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 7909743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:34:32+00:00 2026-06-03T12:34:32+00:00

A really simple question here. I have a label on one view and a

  • 0

A really simple question here. I have a label on one view and a UITableView on the previous view. I have got a segue triggered when the user selects the row and I want the label to be updated with the text from that row. Here’s one example, the code is pretty obvious.

- (void)tableView:(UITableView *)tableView 
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSString *countrySelection;

switch (indexPath.section) {

    case kFirstSection:
        countrySelection = [[NSString alloc]
                            initWithFormat:@"The country you have chosen is %@",
                            [self.MyCountries objectAtIndex: indexPath.row]];
        [self performSegueWithIdentifier:@"doneResults" sender:self];
        self.countryResult.text = countrySelection;
break;

The label isn’t updated and I just don’t know what should be done.

Thanks in advance!

  • 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-03T12:34:40+00:00Added an answer on June 3, 2026 at 12:34 pm

    These kind of things really need to be set on the View Controller that owns them. Use a public property to pass the value of the selected country to that view controller as outlined below:

    First, create a property called something like:

    @property(non atomic,strong) NSString *countryChosen;
    

    in the destination View Controller, and make sure to @synthesize it

    No reason to create another property for the IndexPath. Just use

    // Pass along the indexPath to the segue prepareForSegue method, since sender can be any object
    [self performSegueWithIdentifier:@"doneResults" sender:indexPath]; 
    

    in the didSelectRowAtIndexPath method.

    Then in the prepareForSegueMethod:

    MyDestinationViewController *mdvc = segue.destinationViewController;
    NSIndexPath *indexPath = (NSIndexPath *)sender;
    
    mdvc.countryChosen = [self.MyCountries objectAtIndex: indexPath.row]];
    

    On the viewDidLoad event of the Destination VC, just use:

    self.countryResult.text = countryChosen;
    

    * EDIT *
    To deal with a datasource that has multiple sections, just use the same logic that you have in the cellForRowAtIndexPath.

    NSDictionary *selRow = [[self.countriesIndexArray valueForKey:[[[self.countriesIndexArray allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)] objectAtIndex:indexPath.section]] objectAtIndex:sindexPath.row];

    Change this to suit your needs, but basically you are implementing the same logic that you would to display a cell, except you are specifying the indexPath (both section and row) that you want.

    Then something like the following to set that property on the destination VC:

    self.countryResult.text = [selRow valueForKey@"Country"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is one very simple question(or at least at first sight).Let's say we have
I have a really, really simple CSS question that has already been asked here
I've got a really simple rails question here but I can't seem to find
Really simple question here but bugging me for long enough to ask. Code looks
My question is really simple. When should I use List, IEnumerable and ArrayList. Here's
Really simple question: From within GWT I want to forward the user away from
This is a really simple question which I'm struggling with. I have a variable
I have a really simple question, yet I can't find an answer for it.
It's a pretty simple question, I always have to go check here and then
iv got a really simple javascript question. Ill be using query for parts 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.