To save the data in the UserDefaults, first, we need to get the reference to the UserDefaults by using the standard property.
The following code can be used to save a string in the UserDefaults.
let token = "ABCDEFGD!@#$456MK"
UserDefaults.standard.set(token, forKey: "userToken")