forum

Home / DeveloperSection / Forums / Warning messages of ‘@class Vs. #import’

Warning messages of ‘@class Vs. #import’

Tarun Kumar 1847 02-Sep-2015

It is to my understanding that one should use a forward-class declaration in the event ClassA needs to include a ClassB header, and ClassB needs to include a ClassA header to avoid any circular inclusions. I also understand that an #import is a simple ifndef so that an include only happens once.

My inquiry is this: When does one use #import and when does one use @class? Sometimes if I use a @class declaration, I see a common compiler warning such as the following:

warning: receiver 'FooController' is a forward class and corresponding @interface may not exist.

Would really love to understand this, versus just removing the @class forward-declaration and throwing an #import in to silence the warnings the compiler is giving me.


Updated on 02-Sep-2015

Can you answer this question?


Answer

1 Answers

Liked By