Lets say I have two viewcontrollers A and B. From A to B, I add the viewcontroller B on top of A. On popping, I call the following method in B
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
NSUserDefaults *userSettings = [NSUserDefaults standardUserDefaults];
[userSettings setObject:firstName.text forKey:@"FN"];
[userSettings setObject:lastName.text forKey:@"LN"];
[userSettings synchronize];
}
This userInfoUpdate method updates the NSUserDefaults object for the application. On returning back to viewcontroller A, I call the following method in A:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSUserDefaults *userSettings = [NSUserDefaults standardUserDefaults];
profileTextField.text = [NSString stringWithFormat:@"%@ %@",[userSettings objectForKey:@"FN"],[userSettings objectForKey:@"LN"]];
}
But this doesn't update textfiled string. Any idea what I'm doing wrong here? Is there a better alternative?