I have singleton class has lan variable .it is simple like this
class Settings{
// singelton
static let shared = Settings()
var lan:String? = "ar"
private init(){
}
}
and I have a button which change language code for application from ar to en and when I tabbed it again language code changed from en to ar .
@IBAction func languageBtnTabbed(_ sender: Any) {
MOLH.setLanguageTo(MOLHLanguage.currentAppleLanguage() == "en" ? "ar" : "en")
print(MOLHLanguage.currentAppleLanguage())
Settings.shared.lan = MOLHLanguage.currentAppleLanguage()
MOLH.reset()
}
my question is how to update lan variable on setting class with "MOLHLanguage.currentAppleLanguage()"
I tried to update lan variable by using this line : Settings.shared.lan = MOLHLanguage.currentAppleLanguage() but in the fact the lan variable did not change . can any one help me to solve this problem ? and thanks in advance.
i tried to didset{} on lan variable to update it once the language code is changed and the code worked well .
print("Settings.shared.lan: \(Settings.shared.lan)")
just beforeMOLH.reset()
to display any change.print("Settings.shared.lan: \(Settings.shared.lan)")
just beforeMOLH.reset()
as I suggested, does not show the change inlan
?