Search code examples
iphoneios4

Saving data in a UITextField when switching between UIViewController


(first UIViewController)I have several UITextfields that will have some number value within them. I use a UIButton to switch to my (second UIViewController). Its when I switch back to my (first viewController) that my information gets reset. How do I save that data?


Solution

  • You could use NSUserDefaults:

    [[NSUserDefaults standardUserDefaults] setObject:variableTextField forKey@"Key"];
    
    NSString *email = [[NSUserDefaults standardUserDefaults] objectForKey:@"Key"];
        
    emailLogin.text = email;