Reputation: 477
I am trying to create a property for an instance of a viewController, like so,
@property (strong, nonatomic) DetailsViewController *videoViewController;
but I get an error saying that:
DetailsViewController
is an unknown type name
The view controller is definitely imported like so,
#import "DetailsViewController.h"
Why is this happening?
Upvotes: 0
Views: 101
Reputation: 1677
To avoid Circular imports, always write Import statements in .m file, and use forward declaration in .h file.
In .h file
@class DetailsViewController;
In .m file
#import "DetailsViewController.h"
For private properties, use Objective - C extensions, i.e,
Im .m file
#import "DetailsViewController.h"
@interface MasterViewController ()<YourProtocolList>
@property(nonatomic, strong) DetailsViewController *detailViewController;
@end
@implementation MasterViewController
//Your implementation stuff
@end
In case of inheritance, you may need to import in .h file.
Upvotes: 1