Possible Duplicate:
viewDidLoad being called before didSelectRowAtIndexPath
I am trying to pass variables over to the new view. I have the following code:
appDelegate *dataCenter = (AppDelegate*)[[UIApplication sharedApplication] delegate];
dataCenter.myVariable = [array objectAtIndex:indexPath.row];
in the
didSelectRowAtIndexPath
of the calling view. However, the issue that I have is that this variable is empty in the vewDidLoad function of the next view, simply because it fired off BEFORE the didSelectRowAtIndexPath of the calling view. I am using storyboard to link the views together. Both are UITableView.
If I hit back and then reselect the table element it is then set, granted that by the time I hit back and then selected again, the variable got set. Is there any way to for the order of execution? I really don’t want to do UI view switching on the back end.
Any help is greatly appreciated!
How about saving the data to an NSUserDefaults at didSelectRowAtIndexPath
And then at viewDidLoad read that saved data from NSUserDefaults.
And in the new view that’s loaded:
Hope that helps