How to fix "Protocol Not Implemented"

user4951 picture user4951 · Jun 27, 2011 · Viewed 17.6k times · Source

When I make a new controller called TestController, I insert

<UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate,UISearchBarDelegate>

to the interface of Test.h

When I run the app on the simulator, there are many issues that say "incomplete implementation" and "method in protocol not implemented"

I know some method is not implemented, but which one? How do I know what method I should add?

Answer

Steven Fisher picture Steven Fisher · Oct 20, 2011

Show the issues navigator and expand one of the "method in protocol not implemented" issues. The first detail item will show you where the method is defined in the headers (and, thus, which @protocol it's in). Even better, though, the second detail will show you the name of the protocol.

Switch to the Issues navigator. Ignore the Incomplete implementation message, and look at the Method in protocol not implemented message. You can expand this message to get more information that the compiler provided. The first detail is what you're looking for:

Method declared here

You can see here that I've forgotten to include a method for tableView:numberOfRowsInSection:. I can copy this declaration and paste it into my own code to start writing the method.

Note that there are three issues in my issue navigator. The third is another missing method, which can also be expanded and copied in the same way.