I’ve saved some input from a UITextField using the following code:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:myTextField.text forKey:@"myTextFieldKey"];
[defaults synchronize];
I’d like to display this saved text on a UILabel in another view controller.
I tried this:
myLabel.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"myTextFieldKey"];
but nothing displays. Any help with this would be great. thanks.
Well the loading and saving code is correct, so it looks like the problem is something else.
Try this to debug:
Now you will see if the value retriever from the
NSUserDefaultsis set and if the label is assinged.