@interface A
@property(nonatomic,strong) B *b;
@end
#import “A.h”;
@interface C
@property(nonatomic,strong) A *a
@end
In this example, C imports A and needs also B because A has a property of type B. It would be bad to import B in C so you can import B in A.h. However importing B.h in A.h would result that any class importing A would also import C. And that would cause long compilation time.
To prevent that in A.h you can forward declare B.h and in A.m(implementation file) you can import B.h.
@class B;
@interface A
@property(nonatomic,strong) B *b;
@end
#import “B.h”
@implementation A
@end
Also forward declaring prevents the problem of both classes referring to each other. If A needs B and B needs A and if you import both files in header file (with import statement), compilation would not end up correctly. If you use include, instead of import, the compilation would stop because of infinite loop.
