Xcode 4.3.2给出错误“不能使用super,因为它是一个根类”

时间:2012-04-11 20:45:06

标签: ios xcode

最近当我更新到xcode 4.3.2时,我遇到了很多新问题。在我的应用程序视图控制器m文件中,我不断收到错误“不能使用super,因为它是一个根条款。”

我在互联网上看了好几个小时,所以任何帮助都会受到赞赏。

由于

- (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

3 个答案:

答案 0 :(得分:7)

如果您的类继承自另一个自定义类,并且您在头文件中使用了祖先类(@class MyAncestorClass)的前向声明,但忘记了#import您的祖先,则也可能出现此错误实现文件中的类。

答案 1 :(得分:4)

当你宣布你的课时,你可能忘记了@interface行中的超类。例如,你做了

@interface MyClass
{
    // ... ivars ...
}

// ... methods ...

@end

你希望第一行是:

@interface MyClass : NSObject

或您打算使用的任何超类。

答案 2 :(得分:-1)

使用此解决方案有助于您在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
相关问题