Difference between @Class and #import in Objective C

@Class- Is used when we only want to declare the object of any class..
   For example:

in .h file

@class Mindfire;

@interface MindfireSolutions :UIViewController
{
   Mindfire*   _mindfire;
   ----

}

This is done because neither we want to use the methods of "Mindfire" Class at this time nor we want to set the delegate of "Mindfire"  class. Hence we can use this to increase the compiler speed.
 
 
 
and in .m file do not forget this step to use the methods of this class or to access the variables of this class.

#import Mindfire.h
#import MindfireSolution.h

@implementation MindfireSolution
-
-
-

@end
 
Now we have done this because we will use the methods of this class in .m only.

#import- It is always used when we want use the methods of any class or we want to set delegate for that class.
For example:

in .h file

#import Mindfire.h

@interface MindfireSolutions:UIViewController<MindfireDelegate>
{
   Mindfire*   _mindfire;
------
}
 
#import is used in .h file only when we are setting the delegate for any class.

你可能感兴趣的:(@class,#import,class前置声明)