Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

theprizerevealed

macrumors regular
Original poster
Feb 26, 2016
183
12
I have a bunch of variables set in a viewcontroller just after Import UIkit and just before the class 'classname' { } .

After I dismiss the viewcontroller so that I return to the root view controller then I might want to return to this viewcontroller. I need to reset all the variables to their original values. How do I do that? thanks for your help
 
  • Like
Reactions: basher

casperes1996

macrumors 604
Jan 26, 2014
7,421
5,534
Horsens, Denmark
I think I'm confused here. Why are you having your variables as global variables and not within the class, especially if they are associated with the view anyway? But if I understand you correctly, you want them reset when you enter the view again; So just have a method that gets called when the view appears that sets them
 

basher

macrumors 6502a
May 27, 2011
571
136
Glendale, AZ USA
I have a bunch of variables set in a viewcontroller just after Import UIkit and just before the class 'classname' { } .

After I dismiss the viewcontroller so that I return to the root view controller then I might want to return to this viewcontroller. I need to reset all the variables to their original values. How do I do that? thanks for your help

You can use the ViewController life cycle method called, viewWillAppear. In the body of the method put in the code to set values of your global vars.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.