0

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?

stema
  • 90,351
  • 20
  • 107
  • 135
saikiran
  • 3
  • 2

2 Answers2

0

You should look into delegates. It allows one view to provide a callback to another view without creating tight coupling.

http://www.theappcodeblog.com/2011/04/15/passing-data-between-views-tutorial-using-a-protocol-delegate-in-your-iphone-app/

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];
Community
  • 1
  • 1
bryanmac
  • 38,941
  • 11
  • 91
  • 99
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