Protocol composition in Swift and Objective-C

Protocols are a powerful tool. They allow us to specify contracts between classes that consume them, while also allowing us to segregate interfaces and invert control. However, when we want to declare protocol members as optional, we are forced to diminish the robustness of our code. In this post, Jesse Squires examines this problem, and proposes a number of approaches to make dealing with optional protocol members a bit more robust. One of these approaches, using nested protocols, is particularly elegant.