Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to send text from text field to another view controller
    text
    copied!<p>I'm making an app that behaves something like the default Messages.app in iPhone where a user composes a text message in a <code>UITextField</code> and upon tapping the Send button, the value of the <code>UITextField</code> in <code>ComposeViewController</code> will be transferred to the table cell's <code>UILabel</code> in a custom cell in <code>MasterViewController</code> and also to the <code>DetailViewController</code> where another <code>UILabel</code> will get the text value from the <code>UITextField</code>. The <code>DetailViewController</code> is the <code>ViewController</code> loaded when the user taps the cells from the <code>UITableViewCells</code>.</p> <p>I actually read related articles below but it doesn't work on my end.</p> <ul> <li>How to send the text from textfield to another class?</li> <li>How to see text from one text field in another text field?</li> <li>How to send text field value to another class</li> </ul> <p>Can you please guide me on how to properly implement this? I know it's easy. I just don't know why it's not working. ComposeVC is a <code>ModalViewController</code> while DetailVC is the view that loads when the user taps the cell in the MasterVC's table.</p> <p>Thanks a lot!</p> <p>Below is my code for ComposeVC.h:</p> <pre><code> UITextField *messageTextField; @property (nonatomic, retain) IBOutlet UITextField *messageTextField; - (IBAction)buttonPressed:(id)sender; </code></pre> <p>for ComposeVC.m</p> <pre><code> synthesize messageTextField; -(IBAction)buttonPressed:(id)sender { DetailVC *detailVC = [[DetailVC alloc] init]; detailVC.messageText = messageTextField.text; } </code></pre> <p>for DetailVC.h</p> <pre><code> NSString *messageText; @property (nonatomic, copy) NSString *messageText; </code></pre> <p>for DetailVC.m</p> <pre><code> @synthesize messageText; - (void)viewLoad { testLabel.text = messageText; } </code></pre> <p>testLabel is the UILabel inside my DetailVC.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload