Get error `NSUbiquitousKeyValueStore` this class is not key value coding-compliant for the key

Viewed 365

I'm trying to use iCloud key-value using NSUbiquitousKeyValueStore class. But when I try to get value by specified key, I get an error

[<NSUbiquitousKeyValueStore 0x6000002983d0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key "some_key"

How can I solve this?

1 Answers

It's possible you're getting this error if the value you're trying to store is not exposed to the objective-c runtime (like an optional value type for instance). Try converting your Int/Double/etc to a non-optional NSNumber and then retrieving it via object(forKey:) instead.

Related