How do I make my class conform to an external protocol? It can't find it but I was under the impression I shouldn't import in .h files

StackOverflow https://stackoverflow.com/questions/21943606

Frage

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?

Keine korrekte Lösung

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top