didSelectRowAtIndexPath being called after viewDidLoad of the called view

Posted by Serguei Fedorov on Stack Overflow See other posts from Stack Overflow or by Serguei Fedorov
Published on 2012-11-11T22:58:51Z Indexed on 2012/11/11 22:59 UTC
Read the original article Hit count: 147

Filed under:
|
|

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!

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about ios