cvinette
cvinette

Reputation: 71

Class defined without specifying a base class. Cannot find interface declaration for UIViewController

I have a created a new project and added a new class called MyViewController. My code compiles fine when MyViewController is a subclass of 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 is wrong with my header file?

MyViewController.h

#import <Foundation/Foundation.h>

@interface LBAHypnosisViewController : UIViewController

@end

Upvotes: 3

Views: 4725

Answers (1)

CrimsonChris
CrimsonChris

Reputation: 4641

Foundation doesn't 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 their prefix header. This automatically includes them in every file. Older versions of Xcode would do this for you when creating a new project.

Upvotes: 10

Related Questions