Global variables

Hello again. Could you please tell me how global variables are created and how I can synchronize their value between program launches. For example, if we are talking about id-token.

Hello again.
For global variables you can use Singletons of models.
Models are data structures that have properties, so you can add your specific properties in order to handle your tokens or anything else.
In order to be able to access the tokens from anywhere in the app, we have the singletons which is a global variable of each model. Each model can have only one singleton instance which is auto created during the launch of your app.
In order to save your values between launches, you can use the UserDefaults feature. UserDefaults is a storage that can store small values that are maintained between app launches.
So when you change a token you will need to call the save method in the singleton.
The load of the singleton can happen anytime during the launch of the app but is a good practice to do it when your Launch screen is loaded.

I tried to make some screenshots of the process but feel free to ask for more in any step.

Tokens Model with the functions and property

Load token function in Tokens Model

Save tokens function in Tokens Model

Load tokens singleton function to add in your launch screen


And the steps to add call it when your screen loads

And finally the function to save the token when you have it from anywhere.