I am using the UserDefaults to store a values into the preferences.
I have a template class and a method to get the value ( needed to be overridden )
func getValue(_ value: T?) -> Any?
{
return value
}
When i'am calling:
UserDefaults.standard.set(getValue(value), forKey: "pref_key")
where value can be nil,
i get this error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to insert non-property list object null for key pref_key'
Wasn't it supposed to remove the key if the value is nil?
nilorNSNullfrom yourgetValuemethod? - rmaddyNSNullin UserDefaults. - rmaddy