Xcode 4.3.2给出的错误“不能使用超级,因为它是一个根类”
最近当我更新到xcode 4.3.2时,我遇到了许多新问题。 在我的应用程序视图控制器m文件,我不断收到错误“不能使用超,因为它是一个根子句。
我已经在网上看了几个小时,所以任何帮助,将不胜感激。
谢谢
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. } - (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } @end
当你声明你的类时,你可能会忘记@interface
行中的超类。 例如,你做到了
@interface MyClass { // ... ivars ... } // ... methods ... @end
你想要的第一行是:
@interface MyClass : NSObject
或者你打算使用的任何超类。
如果您的类inheritance自另一个自定义类,并且您的头文件中使用了祖先类( @class MyAncestorClass
)的前向声明,但忘记在实现文件中@class MyAncestorClass
您的祖先类,也可能出现此错误。
使用这个解决scheme将帮助你在phonegap中遇到这个问题
#import <Cordova/CDVViewController.h> #import <Cordova/CDVCommandDelegateImpl.h> #import <Cordova/CDVCommandQueue.h> @interface MainViewController : CDVViewController @end @interface MainCommandDelegate : CDVCommandDelegateImpl @end @interface MainCommandQueue : CDVCommandQueue @end