How to safely send @optional protocol messages that might not be implemented

On 24/10/2011, in Bloques, Cocoa OSX, Cocoa Touch, English, Objective C, by frr149

@optional methods in Objective C protocols Objective C 2.0 added support for @optional methods in protocols. Whatever class conforms to the protocol, it won’t be forced to implement “empty” methods if it doesn’t need them. This is certainly handy for the client conforming to the protocol. Unfortunately, it makes life miserable on the other side. [...]

Tagged with: