I want to observe the value stored in UserDefaults.standard under the key: com.apple.configuration.managed , so I did this:
UserDefaults.standard.addObserver(self, forKeyPath: "com.apple.configuration.managed", options: [.new, .old], context: nil)
Then I implemented this:
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
}
When I start the watchValue application ... it is never called when this default value is changed, instead, Xcode crashes this error:
*** Application termination due to an uncaught exception "NSUnknownKeyException", reason: "[addObserver: forKeyPath: @" com.apple.configuration.managed "options: 1 context: 0x0] was sent to an object that does not meet the KVC requirements for" com ', Property'.
com.apple.configuration.managed UserDefaults.standard?