I’m using Xcode 4, have a simple class interface defined and I added NSTableViewDelegate and NSTableViewDataSource protocols to the interface definition. I.e,
@interface foo : NSObject < NSTableViewDelegate, NSTableViewDataSource>
In my build settings, I have confirmed that the option “Incomplete Objective-C Protocols” warning is enabled (for Debug/Any Architecture etc) and I should get a compile time warning for the non-optional methods required for the NSTableViewDataSource protocol. However, I get no warnings at all but then at runtime I see the message in the log that the methods aren’t defined.
Anyone know why?
If you look at Apple’s NSTableView.h, you’ll se this:
So the comment and the documentation claim that the methods are required, but the code says they’re not. The compiler ultimately ignores all comments and documentation happily altogether. 😉 Hence you’re not getting a compiler warning.
I guess it was their intention to make these two methods required (would make lots of sense), but discovered that lots of their own code relies on it being an informal protocol still. So instead of the headache of changing all the legacy code, I assume they decided to not make them required just yet. I’d expect this to change in Lion though.