我從第三方類派生的迴應,當我嘗試調用基類的方法,我得到的x可以不爲y編譯器警告做出迴應。Objective-C的派生類可能不是基類的方法
我怎樣才能刪除警告?
攝製:
@interface ThirdPartyBaseClass : NSObject {}
+(id)build;
-(void)doStuff;
@end
@implementation ThirdPartyBaseClass
+(id) build{
return [[[self alloc] init] autorelease];
}
-(void)doStuff{
}
@end
@interface MyDerivedClass : ThirdPartyBaseClass {}
+(id)buildMySelf;
@end
@implementation MyDerivedClass
+(id)buildMySelf{
self = [ThirdPartyBaseClass build];
[self doStuff]; // compiler warning here - 'MyDerivedClass' may not respond to '+doStuff'
return self;
}
@end
謝謝!
這仍然產生了「可以不迴應...」警告 – zadam 2010-03-11 19:28:23