我在程序集中有这个初始化器:
- (id<APBSearchWireframeInterface>)searchWireframe {
return [TyphoonDefinition withClass:[APBSearchWireframe class] configuration:^(TyphoonDefinition *definition) {
[definition injectProperty:@selector(searchViewController) with:[self searchViewController]];
[definition injectProperty:@selector(mapFromSearchInput) with:[[self mapAssembly] mapWireframe]];
}];
}
最后一行,当注入(inject) mapFromSearchInput
时,我收到警告
undeclared selector 'mapFromSearchInput'
我在 APBSearchWireframe
的私有(private)扩展中拥有这两个属性
@interface APBSearchWireframe()
@property (nonatomic, readwrite, strong) id<APBSearchView> searchViewController;
@property (nonatomic, readwrite, strong) id<APBMapFromSearchInput> mapFromSearchInput;
@end
并且mapWireframe
符合几个接口(interface)
- (id<APBMapWireframeInterface, APBMapFromSearchInput>)mapWireframe;
如果我将属性定义从私有(private)扩展名移动到 .h,警告就会消失。为什么第二次注入(inject)时出现错误,而第一次注入(inject)时却没有?我已正确完成所有导入,应用程序运行良好,但这个警告真的很烦人......
谢谢。
最佳答案
您是否确保:
- 您在 .h 文件中使用前向声明(即
@class Something
)并在 .m 中使用#import
?
如果是这样并且错误仍然出现,那么编译器似乎变得困惑了。你可以:
- 使用 sel_registerName 预先声明选择器
- 抑制这个特定的警告
例子:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
... your code here ...
#pragma clang diagnostic pop
关于ios - 接收未声明的私有(private)属性(property)选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28579604/