FROM : Jean-Daniel Dupas
DATE : Sun Apr 20 17:32:14 2008
You should avoid to include headers from other headers whenever
possible. It reduce include graph complexity and improve build time.
For example, you do not have to include the ClassTwo.h to declare a
ClassTwo ivar. Just tell the compiler that ClassTwo is a class (and
import ClassTwo.h from your ClassOne.m file only)
To tell the compiler that ClassTwo is a class, just use the @class
directive:
@class ClassTwo;
@interface ClassOne : NSObject {
ClassTwo *ivar;
}
@end
Le 20 avr. 08 à 17:25, Don Arnel a écrit :
> I have two different class objects that need to know about each
> other (see below). But if I include the header from one class inside
> the header of the other class the compiler complains. Is this even
> possible?
>
> ClassOne.h:
> ----------------
>
> #import "ClassTwo.h"
>
> @interface ClassOne : NSObject {
>
> ClassTwo *objectTwo;
> }
>
> @end
> ----------------
>
>
> ClassTwo.h:
> ----------------
>
> #import "ClassOne.h"
>
> @interface ClassTwo : NSObject {
>
> ClassOne *objectOne;
> }
>
> @end
DATE : Sun Apr 20 17:32:14 2008
You should avoid to include headers from other headers whenever
possible. It reduce include graph complexity and improve build time.
For example, you do not have to include the ClassTwo.h to declare a
ClassTwo ivar. Just tell the compiler that ClassTwo is a class (and
import ClassTwo.h from your ClassOne.m file only)
To tell the compiler that ClassTwo is a class, just use the @class
directive:
@class ClassTwo;
@interface ClassOne : NSObject {
ClassTwo *ivar;
}
@end
Le 20 avr. 08 à 17:25, Don Arnel a écrit :
> I have two different class objects that need to know about each
> other (see below). But if I include the header from one class inside
> the header of the other class the compiler complains. Is this even
> possible?
>
> ClassOne.h:
> ----------------
>
> #import "ClassTwo.h"
>
> @interface ClassOne : NSObject {
>
> ClassTwo *objectTwo;
> }
>
> @end
> ----------------
>
>
> ClassTwo.h:
> ----------------
>
> #import "ClassOne.h"
>
> @interface ClassTwo : NSObject {
>
> ClassOne *objectOne;
> }
>
> @end
| Related mails | Author | Date |
|---|---|---|
| Don Arnel | Apr 20, 17:25 | |
| Jean-Daniel Dupas | Apr 20, 17:32 | |
| Jonathan del Strot… | Apr 20, 17:32 |






Cocoa mail archive

