views:

36

answers:

1

I'm pretty sure that I'm going to feel really dumb when I remember how to do this, but here it is:

I have two classes A and B. A has an object of type B, B has an object of type A. This is not that unusual. The problem is that A.h needs to import B.h and vice versa. However, one of them has to happen first, and when it does, the use of the other fails to compile.

I know there's a really dumb/easy way to do this, and I'm just not remembering it, and my google-fu is weak today...

+6  A: 

In Objective-C, you can declare a class using @class ClassName. So you do @class A before you use it in B, and @class B before you use it in A.

Marvin
evidently, I can't accept theanswer intil it's been around for 10 minutes... (or maybe until the question has been around for 15?) but thanks.
Brian Postow