I’m trying to do some animations on an object that I have setup via IB. I’m adding a forward declaration to my .h like so:
@class MySpecialClass;
and then setup a property like so:
@property (nonatomic, retain) IBOutlet MySpecialClass *specialClass;
I want to be able to hide the specialClass using setAlpha, but I get the following error from xcode when trying to compile.
Receiver type 'MySpecialClass' for instance message is a forward declaration.
Do I need to import my class instead of a forward declaration? I’d like to not have to import anything unnecessary if I don’t have to.
Forward declaration just tells the compiler, “Hey, I know I’m declaring stuff that you don’t recognize, but when I say @MyClass, I promise that I will #import it in the implementation”.
You use forward declaration to prevent stuff like circular includes (MyClass imports YourClass which imports MyClass which…), but the ‘promise’ you make with your code, is that you’ll #import it later