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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:09:27+00:00 2026-06-17T07:09:27+00:00

I am just trying to transfer a simple string from a UILabel in a

  • 0

I am just trying to transfer a simple string from a UILabel in a prototype cell into a label in the next View Controller. Value of label.text in the viewDidLoad of the View Controller is returning (null).

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    mainCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (mainCell == nil) {
        mainCell = [[dictionaryTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    NSString* date = [dateArray objectAtIndex:indexPath.row];
    mainCell.viewLabel.text = date;

    return mainCell;
}


- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    if ([segue.identifier isEqualToString:@"View Segue"]) {
        NSLog(@"View Load Segue Success");

        ViewController *one = segue.destinationViewController;
        one.label.text = mainCell.viewLabel.text;
    }
}

What am I doing wrong here?

  • 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-17T07:09:29+00:00Added an answer on June 17, 2026 at 7:09 am

    You can use indexPathForSelectedRow:

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    
        if ([segue.identifier isEqualToString:@"View Segue"]) {
    
            ViewController *one = segue.destinationViewController;
    
            NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    
            one.textProperty = [dateArray objectAtIndex:indexPath.row];
        }
    }
    

    Or you can also use sender if your segue is from the cell to the next scene, e.g.:

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        if ([segue.identifier isEqualToString:@"View Segue"])
        {
            ViewController *one = segue.destinationViewController;
    
            NSAssert([sender isKindOfClass:[UITableViewCell class]], @"Not cell");
    
            UITableViewCell *cell = sender;
            NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
    
            one.textProperty = [dateArray objectAtIndex:indexPath.row];
        }
    }
    

    Two things to note:

    1. As a matter of good programming style, I am not retrieving the text value from the cell. I’m retrieving the text value from the model. You should not be relying upon the view for information to be passed along. Go back to the model, the original source of the information.

    2. Do not set the text property of the label in the destination controller directly. The controls of the destinationController have not been created yet. You should defer setting controls until the destinationController‘s viewDidLoad. So, instead, create a NSString property in the destination controller:

      @property (nonatomic, strong) NSString *textProperty;
      

      Clearly, you should use a more descriptive name than textProperty, but hopefully you get the idea. Anyway, prepareForSegue can set this new property and the viewDidLoad of the destination controller should then use that NSString property to populate the text property of the UILabel, e.g.:

      - (void)viewDidLoad
      {
          [super viewDidLoad];
      
          self.label.text = self.textProperty;
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just trying to establish whether prototype can do something like $$('#ID a:last').css('color','#111'); Any ideas
Just trying to pull off some SMART info from connected Hard Drives on any
I am trying to transfer my simple website to joomla. I like the design
I'm trying to transfer Rails-generated json into Google Maps markers on a map, but
I'm trying to transfer the following mockup into working dynamic code but I'm having
I'm trying to transfer a Wordpress website into a client's server. The existing website
Right now i'm just trying to do the transfer effect. I have it working
I am trying to implement a very simple file transfer client in python using
I am trying a simple socket based file transfer program to include a ProgressMonitorInputStream,
I'm using a form to transfer some data from one part of a controller

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.