Possible Duplicate:
@class vs. #import
I am Really confused with this,Whats the difference between writing @classname & #import"classname.h" .When Do we go for @classname?
Possible Duplicate:
@class vs. #import
I am Really confused with this,Whats the difference between writing @classname & #import"classname.h" .When Do we go for @classname?
@classname
is a forward declaration
. Nothing gets imported, it just informes the compiler, that the class will exist on runtime.
#import
will actually import the other class -> you can imagine it as a copy it into the file. so the imported classes will get compiled before the one, that it is written in.
@classname
just tells the compiler that the class classname
exists.
#import
really imports the header file so that the compiler not only knows that it exists, but also how it looks. (like ivars, methods etc...)
The @classname just let's the compiler know that the class exists however you'll still need to import the corresponding .h. You can use the @classname in the .h and then import the class in the .m and this will allow you to avoid circular references. You can read more about it here Apple Docs
@className
directive is introduced to overcome cyclic reference of classes, it is also known as Forward Declaration
@class
will just inform the compiler that there is a class named "@className yourClass" no need to worry about that class and in runtime it just refer that class and executes.
#import "className"
will keep a copy of that particular class.