I have a UITextField in the first view, I have to store the text and retrieve onto the next view. Who can help me with this?
Asked
Active
Viewed 78 times
2 Answers
0
You should look into delegates. It allows one view to provide a callback to another view without creating tight coupling.
What exactly does delegate do in xcode ios project?
Another option is to create a shared model (read up on model view controller patterns). It's typical in that pattern to create a model and share data by getting a singleton instance of your model:
MyModel *model = [MyModel sharedInstance];
0
You can use NSUserDefaults to store the data and you can retrieve in any class
To Store:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:userName.text forKey:@"userNameKey"];
To retrieve:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *userName = [prefs stringForKey:@"userNameKey"];

Priyanka Singh
- 250
- 2
- 2