Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use delegate methods to pass objects between two view controllers?
    primarykey
    data
    text
    <p>I'm using the Utility Application project to Xcode 4.2, then I am adding two text fields for each view: <code>main view</code> and the <code>flipside view</code>. Now I wish to assign the value of the <code>flipside</code> text field to mainview text field.</p> <p><strong>MainViewController.h</strong></p> <pre><code> #import "FlipsideViewController.h" @interface MainViewController : UIViewController &lt;FlipsideViewControllerDelegate&gt; { UITextField *nameField; } @property(nonatomic, retain) IBOutlet UITextField *nameField; - (IBAction)showInfo:(id)sender; @end </code></pre> <p><strong>FlipsideViewController.h</strong></p> <pre><code> @class FlipsideViewController; @protocol FlipsideViewControllerDelegate - (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller; @end @interface FlipsideViewController : UIViewController { UITextField *changeText; } @property (nonatomic, retain) IBOutlet UITextField *changeText; @property (assign, nonatomic) IBOutlet id &lt;FlipsideViewControllerDelegate&gt; delegate; - (IBAction)done:(id)sender; @end </code></pre> <p><strong>FlipsideViewController.m</strong></p> <pre><code> #import "FlipsideViewController.h" @implementation FlipsideViewController @synthesize delegate = _delegate; @synthesize changeText; - (IBAction)done:(id)sender { [self.delegate flipsideViewControllerDidFinish:self]; } </code></pre> <p>When the done action starts, i want the <code>changetext</code> value be assigned to <code>nameField</code> text. How do I do this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

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