5

In Xcode, I have a forward class declared so as to avoid a circular import e.g.

@class MyClass;

And then I do a method call on that class e.g.

[MyClass myMethod];

But I get a forward class warning e.g.

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

How can I hide those across my whole project?

cdespinosa
  • 20,661
  • 6
  • 33
  • 39
Matt Williamson
  • 39,165
  • 10
  • 64
  • 72

2 Answers2

24

You use forward class declarations in your header file to prevent circular imports.

You must still import the MyClass header in your .m file. The circular import problem doesn't exist with .m files.

Darren
  • 25,520
  • 5
  • 61
  • 71
3

My answer to a similar question may be of use here.

The basic concept is this:

use @class in header files, and then use #import in the .m files.

Community
  • 1
  • 1
e.James
  • 116,942
  • 41
  • 177
  • 214