I have a method that sets a String
value in UserDefaults
, but when I try to retrieve the value in a print
statement, I get nil
. Can anyone see what I am doing incorrectly?
static func setPreferredUnitsOfMeasurementSystem(_ system: UnitsOfMeasurementSystem) {
// system.rawValue is of type String
UserDefaults.standard().set(system.rawValue, forKey: unitsOfMeasurementSystemKey)
print(UserDefaults.standard().string(forKey: unitsOfMeasurementSystemKey))
}