Mike et al,
OK, I get it -- @optional in a @protocol is kind of like #pragma warning:
in (MS) C++ in that it just tells the compiler to not generate specific
warnings, in this case warnings about a class that doesn't fully implement the
protocol. I thought it would automatically call -resp
Protocols cannot decide or change behaviour of an object. Instead, it is up to
the object in question to adopt the protocol appropriately. Declaring methods
as @optional just means that you have a choice whether to implement or not.
Anyone wanting to call the method should first check if its imp
Bah Dave was faster :).
John,
you can see it this way: With the @optional directive you tell the compiler not
to complain if those methods are missing in your class implementing the
protocol, still the class which invokes those optional methods has to ensure
that those are implemented.
Cheers
@optional is a compile-time directive. It means that objects that conform to
your protocol don't *have* to implement the method when the code is compiled.
However, it has nothing to do with runtime-verification. That is up to you (so
yes, you should be using respondsToSelector:).
If you didn
Hello, all ...
After [re-]reading the Apple documentation, i'm still not clear as to what
@optional really does in a @protocol. I thought that declaring certain messages
as @optional would make the app not crash if a certain message didn't have an
implementation in a class that adopts the prot