If both are same & then why we were calling like this in Objective C?
Please clarify this.
If both are same & then why we were calling like this in Objective C?
Please clarify this.
@class is used for forward reference, to stop cyclic calls.
Class interface i.e., @interface is used to create a blue print / .h / declaration of a class.
@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 the Mindfire
class at this time nor we want to set the delegate of the Mindfire
class. Hence we can use this to increase the compiler speed.
In the .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
is always used when we want to use the methods of any class or we want to set a delegate for that class.
For example, in the .h file:
#import Mindfire.h
@interface MindfireSolutions:UIViewController<MindfireDelegate>
{
Mindfire* _mindfire;
}
#import
is used in a .h file only when we are setting the delegate for any class.