Dependent Key Paths
If user defaults can change separately from this code (and you should probably assume it can), providing correct KVO change notifications can be accomplished by having the singleton observe
NSUserDefaultswithNSKeyValueObservingOptionPrior; postingwillChangeValueForKey:@"mySetting"on the prior callback anddidChangeValueForKey:@"mySetting"on the post callback. But this sucks — it’s wordy and you pay a (small) performance cost even ifmySettingisn’t observed.[…]
It’s valid for dependencies to be specified in either the dispatching or specific methods, all the way up the inheritance chain. Correctly overriding
+keyPathsForValuesAffectingValueForKey:requires some tricky code, which I’ve wrapped in a function MLHOverrideKeyPathsForValueAffectingKey in MyLilKeyPathHelpers.