Specifically detailing what defaults have changed on NSUserDefaultsDidChangeNotification

后端 未结 2 1352
野性不改
野性不改 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条回答
  •  梦毁少年i
    2021-01-22 16:24

    Take a look at Apple's documentation: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html

    At the very end there is a notifications section which states:

    NSUserDefaultsDidChangeNotification This notification is posted when a change is made to defaults in a persistent domain. The notification object is the NSUserDefaults object. This notification does not contain a userInfo dictionary.

    So the NIL userInfo dictionary is a choice Apple made. If you really want this feature I would recommend you submit a comment to Apple via http://bugreport.apple.com/

    I ultimately got around this by just writing some logic to compare the settings in the notification to the ones I had loaded to let me know which ones had changed.

提交回复
热议问题