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