-4

If both are same & then why we were calling like this in Objective C?

Please clarify this.

Misha Zaslavsky
  • 8,414
  • 11
  • 70
  • 116
  • 1
    could just paste two simple pieces of code to understand what you are referring to? – sergio Jan 25 '13 at 11:47
  • 1
    Does [this](http://stackoverflow.com/questions/10019961/objective-c-class-directive-before-interface) answers your questions? – Krishnabhadra Jan 25 '13 at 11:48
  • hi.....i didn't write any code .now i am learning the objective-c , i have doubt at reading tutorial thats why i asking yours – Srikanth venigalla Jan 25 '13 at 12:06
  • 1
    What do you mean by 'class' and 'class interface'? There's no such thing as a 'class interface' in Objective-C... It ain't Java... –  Jan 25 '13 at 12:08

2 Answers2

2

@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.

Community
  • 1
  • 1
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
0

@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.

Jamal
  • 763
  • 7
  • 22
  • 32
iPatel
  • 46,010
  • 16
  • 115
  • 137