I have two classes. Let's call them Dog
and Cat
.
In Dog
I have an instance of Cat
, and Dog
has a method, harrassCat
. Inside harrassCat
, I invoke a Cat
method, swipeAtDogsNose:
, which uses properties of Dog
to calculate its output.
The problem is in the header files. I import Cat
's header file into Dog
and create a property. I then access this property in harrassCat
.
For now, I have an NSArray
with all the required properties passed as arguments in swipeAtDogsNose:
. I want to directly access the properties of Dog
within swipeAtDogsNose:
, but I cannot import the Dog
header into the Cat
header because it causes a circular dependency and it fails to compile.
I read on Stack Overflow that when you have circular dependency, you can use @class
to access another class. How do I import Dog
using @class
so that the method declaration in Cat.h looks something like this:
- (BOOL)swipeAtDogsNose:(Dog *)theDog;