How can I pass the data/information from one view controller to another in storyboard?
-
I'm using iOS 6.1 and X-code 4.5 so I'm not using *.xib file for view. I'm a beginner and want to make a app in which user will enter his name in main/initial view and then in 2nd view there will be a label in which I will print "Hello USER_NAME". I have made GUI for both views and also I have 2-2 separate files (*.h ,*.m) for both views . till now i can enter the name but 2nd view is not getting that information? suggest simplest way to do this.
-
Answer:
Consider two viewcontrollers, ViewController1 and ViewController2 Create a @property in ViewController2, @property (copy, nonatomic) NSString * stringForVC2; import ViewController2.h in the ViewController1.m file when you are presenting the ViewController2 using the below method - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ if([segue.identifier isEqualToString:@"YOUR_SEGUE_IDENTIFIER"]) { ViewController2 *controller = (ViewController2 *)segue.destinationViewController; controller.stringForVC2 = @"YOUR_STRING_HERE"; // here you have passed the value // } } You can pass strings, numbers etc the same way. Hope it helped.
Shrutesh Sharma at Quora Visit the source
Other answers
Go through this video u will get all idea about flow, and passing value between view controllers
Asad ali Govani
For detail description follow stackoverflow linkhttp://stackoverflow.com/questions/5210535/passing-data-between-view-controllers?page=1&tab=votes#tab-top
Rao Karthik
Related Q & A:
- How can I transfer my address book from one Yahoo account to a new one?Best solution by Yahoo! Answers
- How can i transfer the address book from one yahoo account to another?Best solution by Yahoo! Answers
- How can I move my yahoo bookmarks from one yahoo account to another yahoo account?Best solution by Yahoo! Answers
- How can I import all my contacts from one hotmail address to another?Best solution by Yahoo! Answers
- Can I have my mail forwarded from one yahoo account to another automatically?Best solution by ChaCha
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.