Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass information between storyboard segues?

Tags:

In the app I'm creating, one of the features is that users can submit their own quotes to be displayed in the app. There is one storyboard segue that lets the user enter their name, email and website, and then on the next they type in a quote and the app then posts all of this data to a database. I'm not sure how I can easily pass data from the first storyboard segue to the next, so that it can post all of the information to the database in one go. Thanks in advance for any replies.

like image 589
Carl Goldsmith Avatar asked Dec 21 '11 22:12

Carl Goldsmith


People also ask

How do I transfer data between Tab Bar Controllers?

Go to the storyboard. Select the single view controller by clicking on the title. In the drop-down menu, select Editor>Embed in>Tab Bar Controller. In this size class you can drag a drop and be pretty sure it will show correctly on a iPhone simulator.

How do you pass data from one view controller to another in Objective C?

Inside the DisplayViewController viewDidLoad method, you can set nameLabel. text = name . Now you have successfully pass data forward from one controller to another using prepareForSegue method.


1 Answers

Use the prepareForSegue:sender: method to pass data from the source to destination view controller:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {     if ([segue.identifier isEqualToString:...]) {         MyViewController *controller = (MyViewController *)segue.destinationViewController;         controller.myProperty1 = ...;         controller.myProperty2 = ...;     } } 
like image 78
Ole Begemann Avatar answered Oct 26 '22 07:10

Ole Begemann