25

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?

4
  • 3
    If you look more carefully at the warnings, it should tell you what isn't implemented. Commented Jun 27, 2011 at 3:04
  • 1
    No it doesn't. That's why I ask. Yea I can look around on .h and categories. What about if I have a big class? Commented Jun 27, 2011 at 11:44
  • By the way I know the solution, namely implement the thing I should have. However, what is the easy way to know what I should have implemented. Commented Jun 28, 2011 at 8:12
  • The compiler should tell you. If it didn't, something is broken (or you're using an old compiler). Commented Jun 29, 2011 at 3:15

4 Answers 4

65

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Marked as answer. This is the only reasonable answer.
Is there any way which can automatically fix "method in protocol not implemented" warning? It seems that Eclipse has this function built-in and with a click, Eclipse will help you add the not-implemented methods automatically. Thanks.
Not yet. It'd sure be nice. :)
6

There are two things I can think of which you can look for. First, look in your .h file and see if you have any method prototypes that you may have forgotten to implement, or else implemented and then changed the implementation such that it no longer matched the prototype's method signature.

Second, if the compiler isn't telling you which methods are missing, look at the documentation of UITableViewDelegate, UITableViewDataSource, etc. In the Tasks section, where it lists the various public class and instance methods, it will say "required method" next to any that need to be there. For example, if you class conforms to the UITableViewDataSource delegate protocol, -tableView:cellForRowAtIndexPath: and -tableView:numberOfRowsInSection: are required.

1 Comment

@Wayfarer Sadly, not that I know of.
0

Check your projectname-Prefix.pch file. I got carried away there and imported something I shouldn't have, and that made it look like the one protocol I was implementing in that class was not implemented, when in fact it was. Just go ahead and make sure you aren't including any protocols there.

In my case it was because the file I shouldn't have imported was another protocol file, that was not directly related to the class where I was getting the warning.

Also when you clean out your *-Prefix.pch file, make sure you close and re-open Xcode. I had to do that to get it to take.

Hope this helps!!

Comments

0

Check your implementation file to see if you have included the there. If you have that bit, you need to delete it.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.