The class is defined without specifying the base class. Could not find interface declaration for UIViewController

I have a new project and added a new class called MyViewController

. My code compiles fine when MyViewController

subclassed NSObject

, but when I change it to inherit from UIViewController

I get these two error messages:

Class "MyViewController" defined without specifying a base class

      

and

Cannot find interface declaration for "UIViewController", superclass of "MyViewController".

      

What's wrong with my header file?

MyViewController.h

#import <Foundation/Foundation.h>

@interface LBAHypnosisViewController : UIViewController

@end

      

+3


source to share


1 answer


The foundation does not include UIViewController

, which is part of UIKit. Add this to your header file.

#import <UIKit/UIKit.h>



You may notice that many projects include both Foundation and UIKit in the prefix header. This automatically includes them in every file. Older versions of Xcode will do this for you when you create a new project.

+10


source







All Articles