如何压制Objective-C警告“类'SomeClass'的不完整实现”?

时间:2010-08-12 04:50:03

标签: objective-c dynamic implementation warnings clang

我有一个将许多消息路由到内部组件实例的类。所以该类只有方法定义,但没有实现。如何针对这些动态方法抑制这些警告?

更新

我的代码示例:

@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

1 个答案:

答案 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