News for hackers. Stuff that matters.
Re:NSNotificationCenter is Probably an Anti-Pattern by fleitz on Saturday January 02, 2016 @04:20AM (#10825643)
Very much agree, almost every time I've seen custom notifications they've been a huge source of pain across the app.
Re:NSNotificationCenter is Probably an Anti-Pattern by amm on Saturday January 02, 2016 @05:44AM (#10825795)
(Global) notifications are sometimes the only sane way to deliver a message from one part of your application to another one without explicitly wiring them together. If you're working with some kind of plugin system they're also incredibly useful to deliver state updates to plugged-in components.

Once your codebase reaches a certain size, an event bus is a very powerful pattern that, if applied correctly, will keep your classes/functions/... decoupled.

Naturally, there is a huge potential for misuse, but that argument probably applies to any design pattern.

Re:NSNotificationCenter is Probably an Anti-Pattern by increment_i on Saturday January 02, 2016 @05:06AM (#10825730)
But again, like the author said, they're pretty useful for truly global events from the OS itself. For instance, when the keyboard notification fires, it comes with useful information the app can use at runtime like xy coordinates involving the keyboard which can be used to make calculations on your views independent of the device size.

Edit: Sorry, just noticed your use of the qualifier "custom" there.

Re:NSNotificationCenter is Probably an Anti-Pattern by cageface on Saturday January 02, 2016 @05:00AM (#10825718)
Code that relies on notifications for control flow is very hard to debug and reason about. Much better to set up explicit delegate/observer protocols between parts of your app that need to communicate with each other. You can use something like NSHashTable to manage weak references to a collection of observers that conform to your delegate protocol.