Tips An easy way to maintain UserDefaults key You can use #function literal to get the property name as UserDefault key. In the following example, #function will get replaced by accessToken. Be aware, changing the property names may break functionality for the existing users. extension UserDefaults { var accessToken: String? { get { return string(forKey: #function) } set { set(newValue, forKey:...
Xcode How to set UserDefault Key Value from Launch Argument? This is the best hidden feature of UserDefaults. If you pass a UserDefault key and value as a launch argument this will set new value for that key. You can use this trick to override current value for any key. This will help you a lot in debugging. Here the...