【发布时间】:2011-12-24 07:17:34
【问题描述】:
我收到警告:实例方法 'method' 正在用于不在根类中的 'Class'。
我在静态方法中调用这个方法(在超类中定义)。当我执行代码时,我得到运行时错误:unrecognized selector sent to class。
这个问题能解决吗?是否可以在静态方法内部调用超类方法?
谢谢
编辑:
儿童班:
@interface ProfileClass : GHAsyncTestCase {}
+ (void)testGHUnitSuccess;
@end
@implementation ProfileClass
+ (void)testGHUnitSuccess {
[self waitForStatus:kGHUnitWaitStatusSuccess timeout:10.0];
}
@end
GHAsyncTestCase 是来自 GHUnit 框架的类。也许,在静态方法中无法调用超类方法。如果没有,我将不得不以不同的方式解决它。
解决方案:
我已经创建了我的超类的共享实例并在静态方法中使用了它。
【问题讨论】:
-
我们需要查看您的代码才能理解任何内容。
标签: objective-c static-methods superclass