Re: iPhone: @protocol and @optional

2010-01-05 Thread John Michael Zorko
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

Re: iPhone: @protocol and @optional

2010-01-05 Thread Mike Abdullah
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

Re: iPhone: @protocol and @optional

2010-01-05 Thread Christian Ziegler
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

Re: iPhone: @protocol and @optional

2010-01-05 Thread Dave DeLong
@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

iPhone: @protocol and @optional

2010-01-05 Thread John Michael Zorko
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