1

I need to watch some value in NSUserDefaults.
Is there any way to add observer for multiple key paths. For example:

[[NSUserDefaults standardUserDefaults] addObserver:self
                                        forKeyPath:keyPath1&keyPath2
                                           options:NSKeyValueObservingOptionNew
                                           context:nil];

If it can not be done some way like above, any workaround?

Thanks in advance!

steveluoxin
  • 419
  • 4
  • 14
  • Have a look at the key value observation approach: https://stackoverflow.com/a/15202762/464016 – Lepidopteron Oct 17 '17 at 13:41
  • @Lepidopteron 'observe all values or only one ' is not the approach what I'm looking for. I want to observe specific some values – steveluoxin Oct 17 '17 at 13:47
  • either you register for each keyPath separately or you take the KVO in consideration, where you can easily distinguish between all your "keypaths" at once and handle those differently based on the changed key. How should the application else being able to distinguish your intention? – Lepidopteron Oct 17 '17 at 13:50

0 Answers0