Note that there are some explanatory texts on larger screens.

plurals
  1. POXCode Storybaord - Transfer of data
    text
    copied!<p>I'm new to storyboarding so the answer to this may be simplistic,</p> <p>I've created a viewController in which a UITextField is present. My test is to transfer the data (text) from that text field into a viewController that is pushed onto the screen.</p> <p>The coding that i have is as follows:</p> <p>ViewController1.h - </p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "ViewController2.h" @interface ViewController1 : UIViewController @property (nonatomic, retain) IBOutlet UITextField *inputText; @end </code></pre> <p>ViewController1.m</p> <pre><code>#import "ViewController1.h" @implementation ViewController @synthesize inputText; -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"showTextController"]) { ViewController2 *vc2 = [segue destinationViewController]; vc2.selectedText.text = self.inputText.text; } } @end </code></pre> <p>ViewController2.h - </p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface ViewController2 : UIViewController @property (nonatomic, retain) IBOutlet UILabel *selectedText; @end </code></pre> <p>ViewController2.m</p> <pre><code>#import "ViewController2.h" @implementation ViewController2 @synthesize selectedText; @end </code></pre> <p>The segue between viewController1 and 2 in storyboard is referred to as 'showTextController'.</p> <p>Is this the correct coding for something so simple? Do i need to be using 'ViewDidLoad' method along with the prepareForSegue:sender method?</p> <p>Any help and advice would be greatly appreciated. </p> <p>Simon</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