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
2010-10-20 20:09:53
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
2010-10-20 20:12:52
@Philippe, good point, forgot about that!
Chris Thompson
2010-10-20 20:14:50