I have a UITableviewController
and when a row is selected, I want to pop back to my rootViewController
and have it display the text of the row in table view. What is happening right now is the viewWillAppear
in my regular view controller is being called before the popToRootViewController
function is called, so when it goes to the regular view controller it does not display the text. I have tried using viewDidAppear
also and it doesn't work. Here is the code I have tried:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"row was selected");
user[@"school"] = [[_objects objectAtIndex:indexPath.row] objectForKey:@"title"];
[[PFUser currentUser] saveInBackground];
[self.navigationController popToRootViewControllerAnimated:YES];
}
And then in the regular view controller:
- (void)viewWillAppear:(BOOL)animated
{
NSLog(@"will appear ran");
PFUser *currentUser = [PFUser currentUser];
self.userSchoolLabel.text = currentUser[@"school"];
}
What I see in the console is it prints out
"will appear ran"
and then "row was selected"
How can I fix this problem, also if i call the method popToRootViewController
from the touch of a button on another view controller it works fine, the problem is with the selecting a row, I not sure why?
Thanks for your help in advance. I really appreciate it.