【发布时间】:2012-05-29 11:55:05
【问题描述】:
在学习使用基于导航的应用程序的教程时,我决定使用我的 3.2.6-Xcode 创建一个基于导航的应用程序并使用 Xcode 4.2 打开它,以便按照该版本的教程进行操作。 但是当我在 Xcode 4.2 中打开同一个项目(不更改或添加任何代码)时,4.2 Xcode 给了我 2 个错误说:
RootViewController 不能使用 'super',因为它是一个根类
现在,我的 Xcode 有 4 个类文件:RootViewController.h、RootViewController.m、SaveUpAppDelegate.h 和 SaveUpAppDelegate.m。错误在RootViewController.m:
- (void)dealloc {
[super dealloc];
}
和
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Relinquish ownership any cached data, images, etc that aren't in use.
}
我已经通过互联网搜索并找到了这个讨论(http://stackoverflow.com/questions/10113669/xcode-4-3-2-gives-error-cannot-use-super-because-it-is- a-root-class),他们说原因可能是控制器是开发人员忘记了@interface 行中的超类。这不适合我的情况,因为我(或更好:Xcode 3.2.6)没有忘记RootViewController.h 中的超类...
#import <UIKit/UIKit.h>
@interface RootViewController : UITableViewController {
}
@end
现在,我将那些关键行注释掉了,它工作正常,但我敢肯定,我需要这些行,因为 m 文件中的大多数自动创建的行都是用 [super .... ].
如何解决问题?
【问题讨论】:
-
你尝试清理项目了吗?
-
很抱歉这个愚蠢的问题,但是“清理”项目是什么意思?删除/注释所有自动创建的代码? - 如果你的意思是:是的。我将关键代码注释掉了,它现在可以正常工作了。但我不确定在教程中是否需要该超级代码。这就是为什么我要问是否有其他解决方案,或者“超级”是否可以被其他东西取代。
-
你使用过 ARC(自动引用计数)吗?
-
我的项目说没有 Objective-C++ 自动引用计数(它设置为“否”),我也无法在通过 Xcode 3.2.6 创建项目时设置这样的复选框。
标签: ios xcode xcode4 xcode4.2 xcode3to4