Wednesday, July 23, 2008

Who said Event?

Finally we are approaching to code which manages events...such as MOUSE!! (which in this case would be "finger" perhaps? )

When I first saw Protocols at the index I thought of network connections and sockets. Go no go...

"Protocols declare methods that can be implemented by any class"

bottomline

"As an outsider, all you need to know is what messages you can send (the protocol) and where to send them (the receiver)"

All this is to let the anonymous objects live. We need to call other objects but with just don't know what do they expect from us to obtain a value. Basically we do not care if it's a zebra object we are asking something too. I just want that [zebra] object to send me how many stripes he has and where to send that answer. That's all. That's why we need protocols...to know how many stripes the zebra has and where will the answer will be sent, although we don't even know that we are "talking" to a zebra object.

Definition of a protocol (formal)
@protocol devngoProtocl
method declaration
@end

There is the possibility to define between optional and required methods to the user.

(informal)
@protocol NSObject (devngoProtocol) <--- Which shows the usage of categories for this declaration.
@end

0 comments: