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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:29:59+00:00 2026-05-31T11:29:59+00:00

I am currently using the following code to try to pass the text in

  • 0

I am currently using the following code to try to pass the text in a UITextField between 3 view controllers that are looking at the same ViewController.h and ViewController.m files:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"NameOfSegue"]) {
        ViewController *ibcVC = segue destinationViewController;
        ibcVC.myTextField = self.myTextField;
    }
}

I have 3 view controllers linked in the following order: ViewC1 => ViewC2 => ViewC3.

My UITextField is on ViewC2.

When I click on the button on ViewC2 for example, that Pushes in ViewC3, it passes the data just fine to ViewC3. However, say I am currently on ViewC2, I type something in the UITextView, and I next click on the Back button on the Navigation that Xcode automatically puts there when working with tabbed view applications, it will take me to ViewC1 just fine as expected. However, if I push the button on ViewC1 that Pushes in ViewC2, the Data/Text I typed in my UITextField has been erased or reset to null.

So basically here is the problem using a slight digital visual:

DATA IS PUSHED CORRECTLY EX.

ViewC1 => ViewC2 => ViewC3

DATA IS ERASED IF WE PRESS THE BACK BUTTON ON NAVIGATION EX.

ViewC1 <= ViewC2

  • 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-31T11:30:00+00:00Added an answer on May 31, 2026 at 11:30 am

    One solution is to store your string in a singleton.

    SharedStrings.h =

    #import <Foundation/Foundation.h>
    
    @interface SharedStrings : NSObject{
        NSString *string;
    }
    
    +(SharedStrings *)sharedString;
    -(void)setString:(NSString *)newString;
    -(NSString *)getString;
    
    @end
    

    SharedStrings.m =

    #import "SharedStrings.h"
    
    static SharedStrings *sharedString;
    
    @implementation SharedStrings
    
    -(id)init{
    
        self = [super init];
        string = [NSString new];
        return self;
    }
    
    +(SharedStrings *)sharedString{
        if (!sharedString) {
            sharedString = [[SharedStrings alloc] init];
        }
        return sharedString;
    }
    
    -(void)setString:(NSString *)newString{
        string = newString;
    }
    -(NSString *)getString{
        return string;
    }
    
    @end
    

    You could then have all your views get and set the string as necessary, like so:

    - (void)viewWillAppear:(BOOL)animated
    {
        [myTextField setText:[[SharedStrings sharedString] getString]];
        [super viewWillAppear:animated];
    }
    
    -(void)textFieldDidEndEditing:(UITextField *)textField{
    
        if (textField == enterInfoTF) {
            [[SharedStrings sharedString] setString:textField.text];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently downloading an HTML page, using the following code: Try Dim req As
I am currently using the following code to create a web request: Dim myRequest
I'm currently using the following code to append a X link to each element
I'm currently using the following code (C#): private static void PlayLoop(string filename) { Audio
I'm currently using StructureMap to inject instances of NHibernate ISessions using the following code:
I'm currently using the following PHP code: // Get all subordinates $subords = array();
I am using currently the following code to populate a combobox: combobox.DataSource = datatable;
In short, currently I am using the following code to pull records from multiple
I am currently using PHP_Beautifier for formatting code with the following command like options
Currently I using the following code to get my JSON output from MySQL. <?php

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.