Protocols
When talking about Objective-C, protocol is a concept of Objective-C language, therefore something that can be understood by a compiler. Specifically, you can define it by @protocol
keyword.
A class can declare itself to conform to protocol with the angle syntax:
@interface MyClass <MyProtocol> // class MyClass conforms to protocol MyProtocol
Some people use the word adopt here, as in "class MyClass
adopts protocol MyProtocol
".
This syntax will be understood by the Objective-C compiler, for example it can warn you if there are required methods in MyProtocol
that are not implemented in MyClass
.
Patterns
(Programming Design) Patterns are abstract concepts that can be implemented in any (Turing-complete) language. You write a language-specific code and then tell to humans about this pattern. The compiler will not know whether you call the code some fancy word or not.
Adapter is a specific pattern. It, again, can be used with any programming language, although some languages, e.g. Python make this easier with declarations.
I'm not aware of Conformer concept.
Delegates
Delegate is part of Delegation Pattern. It's used to solve a problem where an object A
wants to do something to object B
and then wants B
to be able to talk to A
. In order to make this conversation possible B
will need to know something about methods of A
, but if A
is a very complicated class and therefore B
may be forced to know "too much".
The delegation pattern solves this problem by explicitly declaring a protocol DelegateOfB
, defined where B
is defined. Then any class that needs to receive information from B
(such as A
) declares that it conforms to DelegateOfB
and implements corresponding methods. Therefore B
does not know anything about A
other than the fact that it conforms to DelegateOfB
.
This pattern can also be implemented in any language, but Cocoa/Cocoa Touch or most other Objective-C frameworks are unusual in that delegation is used 90% of time whenever the aforementioned problem arises.
Here it helps that protocols are a language feature. Again, this pattern could theoretically be used in any language, even assembler :), but it will be more useful for Objective-C, because you are able to declare that a delegate needs to conform to this protocol:
@property id<DelegateOfB> delegate;
and the compiler warns you if it thinks you assign something that doesn't conform to DelegateOfB
.
In other languages, different solutions, such as callback functions, are usually used.