In my controller's header file, I need to declare a instance of another controller. I did it in the following way:
#import "BIDMyRootController.h"
#import "BIDAnotherController.h" //I import another controller's header
@interface BIDCurrentController : BIDMyRootController
//I declare an instance of another controller
@property (strong, nonatomic) BIDAnotherController *anotherController;
@end
The above code is pretty straight forward. No problem!
But I also noticed that, alternatively, I can use @class
to replace my #import
statement for BIDAnotherController
in the following way:
#import "BIDMyRootController.h"
@class BIDAnotherController //I declare another controller with @class tag
@interface BIDCurrentController : BIDMyRootController
//I declare an instance of another controller
@property (strong, nonatomic) BIDAnotherController *anotherController;
@end
No problem too!
But I am confused now, what are the differences between #import "BIDAnotherController.h"
and @class BIDAnotherController
then if they are both ok???
Update:
By the way, in the implementation file of BIDCurrentController
, I have imported BIDAnotherController
again:
#import "BIDCurrentController.h"
#import "BIDAnotherController.h" //import another controller again
@implementation BIDCurrentController
...
@end