Specifically detailing what defaults have changed on NSUserDefaultsDidChangeNotification

后端 未结 2 1375
野性不改
野性不改 2021-01-22 16:01

I\'m starting to get into the inner sanctum of NSUserDefaults to the point where I can now successfully intercept an NSUserDefaultsDidChangeNotification notification using a sup

2条回答
  •  轮回少年
    2021-01-22 16:35

    you can use KVO (Key Value Coding) to track specific keys in the NSUserDefaults. See my answer here with code snippets: https://stackoverflow.com/a/10950217/388412

    Instead of registering as a general observer for any NSUserDefaultsDidChangeNotifications in the NSNotificationCenter, you can register to observe key-value-changes for a specific key of the NSUserDefaults standardUserDefaults object.

提交回复
热议问题