Responds to selector question/thought


#1

Why do we need to check if a delegate responds to the selector(implements a method defined in a protocol)? Wouldn’t the programmer already know this? And if someone is trying to use someone else’s code wouldn’t (we hope) the programmer provide documentation or at least make the code readable enough that you could easily see without much effort what methods the delegate implements? (location 2755, 2775). Wouldn’t it just be easier that once you say you conform to a protocol that the in the delegates implementation file the required methods are stubbed out for you automatically?

Maybe I missed something here…


#2

The idea behind a delegate is that any object could be the delegate. Sure, in this particular application, we know that the CLLocationManager’s delegate is the WhereamiViewController and that it implements that method, but we could be in another application where the delegate doesn’t implement that method.