我有一个将许多消息路由到内部组件实例的类。所以该类只有方法定义,但没有实现。如何针对这些动态方法抑制这些警告?
更新
我的代码示例:
@interface SomeClass : NSObject
{
}
- (void)mssageA:(id)value1 additionalOption:(id)value2;
- (void)mssageB:(id)value1 additionalOption:(id)value2;
- (void)mssageC:(id)value1 additionalOption:(id)value2;
@end
@implementation SomeClass
- (id)forwardingTargetForSelector:(SEL)aSelector
{
if(aSelector==@selector(mssageA:additionalOption:)) return innerComponentInstance;
if(aSelector==@selector(mssageB:additionalOption:)) return innerComponentInstance;
if(aSelector==@selector(mssageC:additionalOption:)) return innerComponentInstance;
return [super forwardingTargetForSelector:aSelector];
}
@end
答案 0 :(得分:1)
我认为协议实现可能看起来像这样
@protocol SomeProtocol
@optional
- (void)mssageA:(id)value1 additionalOption:(id)value2;
- (void)mssageB:(id)value1 additionalOption:(id)value2;
- (void)mssageC:(id)value1 additionalOption:(id)value2;
@end
@interface SomeClass : NSObject <SomeProtocol>
{
}
@implementation SomeClass
- (id)forwardingTargetForSelector:(SEL)aSelector
{
if(aSelector==@selector(mssageA:additionalOption:)) return innerComponentInstance;
if(aSelector==@selector(mssageB:additionalOption:)) return innerComponentInstance;
if(aSelector==@selector(mssageC:additionalOption:)) return innerComponentInstance;
return [super forwardingTargetForSelector:aSelector];
}
@end