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?
#import <Foundation/Foundation.h>
@interface LBAHypnosisViewController : UIViewController
@end
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With