Xcode Tutorial: Using Delegates to Pass Variables Between View Controllers
Why Stack Overflow recommends it
Stack Overflow users link it when answering how to pass data between view controllers in iOS, since it explains delegates in a simple, step-by-step way.
Recommended by 4 people across 4 different months, 2013 to 2015.
What it is
A 17-minute 2013 Xcode tutorial by Rob Smythe for iPhone and iPad programmers. It builds a sample app where a delegate presents a new view controller, collects some data, and passes it back to the original view controller.
What people said
Strong rec Carter · 2013-07 · Stack Overflow · on “Xcode 4.2 & Storyboard, how to pass data between views? Existing code error”
I spent "countless hours" my self trying to find a way to pass data and understand delegates with no comprehension and very little success. This video did something that all the other references I checked didn't do : keep it as simple as possible while clearly showing what was needed. Thank you so very much Mr Rob Smythe. [this video]
Recommends Saad Chaudhry · 2013-12 · Stack Overflow · on “Access Data Variable from one class in another class”
In SecondViewController.h @property (nonatomic, copy) NSString *textblah; In FirstViewController.m #import "SecondViewController.h" // where you want to store value SecondCiewController *secondViewController = [[SecondViewController alloc] init]; secondViewController.textblah = stringToStore; // and [self.navigationController push:secondViewController animated:YES]; // You can log the set value with to check whether it was successful or not. NSLog(@"textblah: %@", textblah); For complete understanding of the code and process you can watch the video tutorial like this [LINK] and this [this video] You will find them informative and easy to understand specially beginners.
Recommends guardabrazo · 2014-02 · Stack Overflow · on “Simple delegate example for iOS not working”
I know there are tons of questions out there about passing messages between different view controllers. I've checked them all but I can't get it working. I've followed this tutorial: [this video] replacing the storyboard with a navigation controller but I run across the following issue over and over again: 'Cannot find protocol declaration for...' Here is the code: FirstViewController.h #import "SecondViewController.h" @interface FirstViewController : UIViewController <SecondViewControllerDelegate>{ //In this line above is where I get the error 'Cannot find protocol declaration for SecondViewControllerDelegate' IBOutlet UITextField *userNameTextField; } @property (nonatomic, strong) UITextField *
Recommends TheJack · 2015-06 · Stack Overflow · on “How do I Create a Default Slider Value Programmatically?”
@PlateReverb did this solve your problem? You could also use delegation as shown here [LINK] and here [this video] . If my (or anyone else's) answers helped you, I would suggest upvoting/marking them as answers!