2

I defined a protocol in ClassA, and want ClassB to conform to it, so in ClassB I have <ClassADelegate>.

It keeps complaining, however, that it can't find that specific protocol. I understand why, I'm claiming to conform to a protocol in the .h file, but that class is #imported in the .m file, so it doesn't know about it yet.

So I tried a forward @class declaration, and even a forward @protocol declaration, but neither one worked, it still doesn't know about the protocol I'm specifying.

My only option left seems to be to import it in the .h file instead of the .m file, but everything I've heard indicates that you shouldn't be importing in the .h, I've been personally bit by circular reference bugs and I'm very hesitant to do this.

What should I do?

Community
  • 1
  • 1
  • 3
    You have to import the .h that defines the protocol into the .h that uses the protocol. – rmaddy Feb 21 '14 at 19:38
  • 6
    I agree with @rmaddy. If you're worried about circular references, you can always take the protocol out of `ClassA` and give it its very own `.h` file which should be safe to import into other classes. – aapierce Feb 21 '14 at 19:46

1 Answers1

0

Try cleaning your project and building it. I had similar problems and doing a clean build fixed the issue.

Rafał Sroka
  • 39,540
  • 23
  • 113
  • 143