I am new in iphone development and i have little bit Question.
My Question is When do we use @class and #import in .h (header )file.And if your answer is @class u can create instance but can not.. use its methods and by use of #import in .h file we can access all method and variable of second class .Then My Question is
if #import contains advantage then why many people used only @class in their .h file.
Please anybody have answer then reply asap.Thanks in Advance.
First of all, you’re right with your assumption.
As for advantages:
The @class directive is faster, since it only discloses the Name, and the Inheritance to the Namespace (e.g. the Header File). But #import loads everything, so it’s slower and means more load on the system. If your Code is a library for another system, its pretty useful if the headerfiles only load the classname (@class)
For an example. You have the class A, and are importing a Headerfile B from a library. B itself wants to use C. If it imports all data in the B Headerfile, it gets bloated, because you would load it too when importing the headerfile into your class A. But it isn’t necessary, that your class A knows what Class C is capable of, because only B is using it.