Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Pass Variable from one UIViewController to another UIViewController

Hello everybody,

quite the simple question I assume, however, one I cannot figure out.

How do I pass a variable created in a function on UIViewController1 to a function in UIViewController2?

I update variable statusHome from false to true and catch it via an didSet on UIViewController1. Now I want to pass the true to a hidden label on UIViewController2 to unhide it.

If you could post some example code I'd be really happy.

Thanks a bunch, Henrik