swift - How do I reset all global variables? -
i want reset global variables when user logs out otherwise of information stay (the info in global variables).
is there way without manually resetting them initial value when log out button pressed?
if understand correctly, saving user-data global variable? doesn't seem make sense me.
if intending equal nsuserdefaults global variables, can use following approach delete data standard userdefaults:
private func cleanuserdefaultsonlogout() { let standarddefaults = userdefaults.standard key in standarddefaults.dictionaryrepresentation().keys { standarddefaults.removeobject(forkey: key) } standarddefaults.synchronize() }
please correct me if i've misinterpreted question.
Comments
Post a Comment