-3 years ago 83
iOS Question

Issue with accessing a variable in another viewcontroller while using a hamburger menu

In a certain viewcontroller say 'viewcontroller1', on clicking a button I am setting a variable. Now I click on my hamburger button(created using SWRevealViewController) and go to another viewcontroller I want to use the value I set in viewcontroller1 in the other viewcontroller. How can I achieve this..Also, I am using swift.

Answer Source

You can set a variable in App Delegate say..'myVariable'. In your 'viewcontroller1' you can set the variable as 'appDelegate.myVariable'. You can use this format to access the variable also from another viewcontroller.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download