tags:

views:

53

answers:

1

I've read the documentation but I'm still confused. Can someone please explain what a protocol is? (You could give code examples but I'm really looking for an explanation)

+6  A: 

Here's a great article on it. Effectively, a protocol in Objective-C is very similar to an interface in Java or a pure virtual class on C++ (although not exactly as pure virtual classes can have data members...). It's basically a guarantee that a specific class knows how to respond to a given set of methods (messages).

Chris Thompson
It's a guarantee unless the protocol defines optional methods. In that case you still have to check if the method is implemented or not.
Philippe Leybaert
@Philippe, good point, forgot about that!
Chris Thompson