0

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?

Prince Agrawal
  • 3,619
  • 3
  • 26
  • 41
matthew
  • 467
  • 8
  • 23
  • Show the complete header file and show the contents of DetailsViewController.h – Gary Jan 05 '14 at 05:24
  • 2
    I think, you are facing circular import problem, seems [duplicate](http://stackoverflow.com/questions/7767811/circular-import-issues-in-objective-c-cocoa-touch) – Bilal Saifudeen Jan 05 '14 at 05:26

1 Answers1

1

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"

OR

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.

Bilal Saifudeen
  • 1,677
  • 14
  • 14