Answer the question
In order to leave comments, you need to log in
Need a variable to get its value in different classes, how to be?
You need to save the username and get its value in different classes, I thought to use UserDefaults, but the key will not be known, what then?
Answer the question
In order to leave comments, you need to log in
The answer is here:
https://medium.com/@nimjea/userdefaults-in-swift-4...
The best thing is to get used to writing correctly.
And it is correct that such a thing as you described never happened.
If you need a variable to be used in different classes - pass it to instances of these classes. Using UserDefaults to pass a variable (???!!!!!!) is the wildest slag.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question