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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:00:48+00:00 2026-06-17T16:00:48+00:00

How can I pass textField data from a UIView Controller text field to a

  • 0

How can I pass textField data from a UIView Controller text field to a tableview label in a cell? I would like to somehow add the textfield data to an Array so that I can set the number of rows return value to the arrays count.

I’ve added an NSMutable array to my model.

In my view controller I’m implementing the prepareForSegue method

  if ([segue.identifier isEqualToString:@"Details"]){

        MileageDetailViewController * mdv = [segue destinationViewController];

        NSString *text;
        startTextField.text = text;
        mdv.label.text = text;

I’ve tried this several different ways. I’ve done this with an array and tried to add text object an array but that didn’t display either. This last way I tried using a label and adding the text from textField to a tableview Label.

 In the tableView I add this code to grab the text from the viewController.

     - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    { 
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return  1;
}

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

    UILabel *labe = (UILabel *) [cell viewWithTag:20];

    labe.text = label.text;

    // Configure the cell...

    return cell;
  • 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-17T16:00:49+00:00Added an answer on June 17, 2026 at 4:00 pm

    The Code examples below are just to get you started. But I strongly, strongly recommend you follow the tutorials on Ray Wenderlich’s site (link) as you seem to just be starting on iOS development.

    Passing data between view controllers using prepareForSegue: (with comments in code block):

    // This will get called before the view appears
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        if ([[segue identifier] isEqualToString:@"Details"]) {
            // Get destination view controller
            MileageDetailViewController *vc = [segue destinationViewController];
    
            // Grab the text field contents and put it into a public property on the new view controller
            vc.myText = self.myTextField.text;
            // NOTE: myText is a public NSString property on your MileageDetailViewController
            // NOTE: self.myTextField is the IBOutlet connected to your Text Field
        }
    }
    

    Now onto the methods in your controller with the table view:

    // Load the model required for the view controller
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        // Load your "model" - in this case an array property (called myData) with a single piece of text
        // NOTE: myText CANNOT be nil or an exception will occur
        self.myData = [[NSArray alloc] initWithObjects: self.myText, nil];
    }
    
    
    // UITableViewDataSource
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    { 
        // Return the number of sections.
        return 1;
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        // Return the number of rows in the section.
        return  [self.myData count];
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath      *)indexPath
    {
        // NOTE: You must have set the reuse identifier in Interface Builder for this to work
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Reuse"];
    
        // NOTE: You must have set the tag in Interface Builder for this to work
        UILabel *labe = (UILabel *)[cell viewWithTag:20];
    
        labe.text = [self.myData objectAtIndex:indexPath.row];
    
        return cell;
    }
    

    Hope this helps; iOS development is a lot of fun but following some tutorials will really help you get up-to-speed.

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

Sidebar

Related Questions

You can pass special strings into jQuery's Datepicker class setDate() method like +7 which
During a search you can pass some data to search manager by using the
If I have a auto_ptr I can pass it for a reference?Like: auto_ptr<MyClass>Class(new MyClass);
I know from here that I can pass an ignore option in the jQuery.validate
I have a text field: <input type=text class=field blink name=j-state[] id=j-state/> The data in
I have VS2008 and windows reports. I want to pass to my text field
I'm having trouble with ASP.NET MVC and passing data from View to Controller. I
I'm trying to append a value (quantity) from a text input field to a
in MongoDb I can pass a predicate to an queryable instance for example DataBase.GetCollection<BsonDocument>(entity)
In JSF 2 you can pass around ids, Strings other things that can be

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.