Search code examples
objective-ciossingletonkey-value-observingnsnotifications

KVO for a singleton with multiple observers?


I'm currently contemplating whether to use KVO or NSNotifications to alert several objects in my iOS app when a property of my singleton has changed.

Since all the objects that need to be notified of the change has a reference to the singleton, KVO would seem like the natural solution. However, I've never used KVO with a singleton and multiple observers, so I don't know if that pattern is advisable or even possible.

Is it a good idea (or even possible) to use KVO on a singleton with multiple observers?


Solution

  • The other answers haven't answered the real questions, whether KVO works with multiple observers observing the same thing on a singleton.

    Testing, however, shows that it works fine, and I haven't seen anything about the practice being wrong.