Reputation: 1645
I have a start screen with a log in button and a register button. Both lead to the same view controller, but its interface is based on a variable.
How can I make my startviewcontroller change this var, that can currently only be accessed from the mainviewcontroller?
Upvotes: 0
Views: 972
Reputation: 9419
You would have to declare that variable global outside any class just below the import
statements. You will be able to use the variable anywhere in your code.
import UIKit
var myGlobalVariable: Int
Upvotes: 0
Reputation: 1215
I'm temped to say "just like you get access to any other classes properties. However, given you haven't shared any code it's may not be as simple. But in general you will need to have a pointer to an instance or shared instance (singleton) of your mainViewController. And of course those variables need to be public.
Upvotes: 1