views:

523

answers:

1

I have two files independant on each other.

Let's just call it Class1 and Class2.

In Class1, I need Class2, and in Class2 I need Class1.

I have a prefix file where I include all my files, and I get some syntax errors because I do

#import "Class1.h"
#import "Class2.h"

How would I define both of them so they can use each other?

What am I doing wrong?

+4  A: 

Look into using a forward declaration. Replace the #import of Class2 in Class1 with @class Class2; and move this #import statement to the implementation Class1.m (and vice versa).

Alex Reynolds
Nice! Thanks :) I've been wondering what @class did, haha.
Johannes Jensen