Company
Date Published
Author
Michael Carroll
Word count
1995
Language
English
Hacker News points
None

Summary

The PubNub Cocoa SDK offers multiple methods to handle incoming messages through subscribed channels, with three primary approaches: using the PubNub singleton client delegate methods, the PNObservationCenter by adding observers, and the core foundation NotificationCenter by adding callbacks to event notifications. The PubNub singleton method involves overriding delegate methods for simple message handling but may lead to code complexity when dealing with multiple channels. The PNObservationCenter adds flexibility by allowing dynamic creation of event handlers using blocks, which improves encapsulation and simplifies logic maintenance. The core NotificationCenter provides similar functionality to PNObservationCenter but is less convenient as it lacks the simplicity of handler blocks. While the tutorial details these methods, it notes the release of an updated iOS SDK (version 4.0) that streamlines and simplifies the SDK, advising developers to refer to a migration guide for upgrading from version 3.x to 4.0.