Search code examples
iosobjective-ccocoadesign-patternsdelegates

Objective-C, Delegate as Adapter Pattern: who is the adaptee?


I've read more than once that the Delegate Pattern used in Cocoa is an implementation of the Adaptern Pattern (http://en.wikipedia.org/wiki/Adapter_pattern). They share the same intent, which is: let two objects with incompatible interfaces to work with each other. The delegate object is the Adapter, because it adopts a protocol required by a client, the class that requires the protocol and has a weak reference to a delegate is the Client (so, this would be a class of the Cocoa framework). My question is: who is the Adaptee? The delegate pattern doesn't wrap itself around any object, from what I've seen, who is the object that needs to be adapted?


Solution

  • I've found a solution in the official documentation, as I suspected there is no adaptee: https://developer.apple.com/legacy/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html#//apple_ref/doc/uid/TP40002974-CH6-SW5