How to observe the event when the specific application settings value has been changed in swift 5?

193 views Asked by At

My application has a multi value settings bundle option. I'd like to catch the event, when this setting has been changed.

I found these possibilities, but I don't know what is the difference between them:

UserDefaults.standard.addObserver(observer: NSObject, forKeyPath: String, options: NSKeyValueObservingOptions, context: UnsafeMutableRawPointer?)

NotificationCenter.default.addObserver(observer: NSObject, forKeyPath: String, options: NSKeyValueObservingOptions, context: UnsafeMutableRawPointer?)

Thanks in advance.

0

There are 0 answers