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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:04:52+00:00 2026-05-27T21:04:52+00:00

I’m having trouble sending data to a different view using the prepareForSegue method… I

  • 0

I’m having trouble sending data to a different view using the “prepareForSegue” method…

I have a tableview that’s populated with results from an sqlite query. When I tap on one of table cells it directs me to another view where I have a label that will tell me the ID and Name of the

I have a NSString that holds the value of an ID from an SQLite datasource. I want to pass that id to the second view of my app, to use it to grab information from the sqlite datasource that’s based off that id.

Now I’ve written code where it’ll pass information from one view to the other… but for some reason the information is “off count”. Here’s what I mean, I have a list of 3 mountain areas: Deception, Far Side, and Mt. Washington (listed in a tableview on the first view). When I click on Mt. Washington, it’ll go to the second view, and the label that I have setup to tell me the name of the selected cell…. is blank. I hit back button on the navigation bar, and tap Mt. Washington again, and this time the label displays the name of “Mt. Washington”. Now when I go back and click on “Far Side”, the label displays “Mt. Washington”. When I go back and click on “Far Side” again, The label changes to “Far Side”. Hopefully that makes sense.

Does any one know how to fix the problem?
Here’s the code I have:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([[segue identifier] isEqualToString:@"areaIDpush"]){
      RockViewController *rockRoutes = [segue destinationViewController];
      rockRoutes.rockID = areaID_fk;
      rockRoutes.rockName = areaName_fk;
    }
}



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {    
   UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
   areaID_fk = cell.detailTextLabel.text;
   areaName_fk = cell.textLabel.text;
}

- (void)viewWillAppear:(BOOL)animated {
[areaIDLabel setText:rockID];
[areaNameLabel setText:rockName];
[super viewWillAppear:animated];

}

Hopefully that’ll help you see where I’m running into problems… any kind of help would be great. Thanks!

  • 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-05-27T21:04:52+00:00Added an answer on May 27, 2026 at 9:04 pm

    Sent my code to a buddy, and he helped me realize what was going wrong.

    Here’s the right code:

    -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
            if([[segue identifier] isEqualToString:@"areaIDpush"]){
            RockViewController *rockRoutes = [segue destinationViewController];
            rockRoutes.rockID = areaID_fk;
            rockRoutes.rockName = areaName_fk;
    
            UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:self.tableView.indexPathForSelectedRow];
            rockRoutes.rockName = cell.textLabel.text;
            rockRoutes.rockID = cell.detailTextLabel.text;
        }
    }
    
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6

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.