ios - 接收未声明的私有(private)属性(property)选择器

标签 ios objective-c typhoon

我在程序集中有这个初始化器:

- (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

如果是这样并且错误仍然出现,那么编译器似乎变得困惑了。你可以:

例子:

#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/

相关文章:

ios - 当用户在 UIButton 上滑动时,UIScrollView 停止工作

ios - 如何创建自己处理协议(protocol)的 UITableViewController 子类

ios - 台风注入(inject)和设置委托(delegate)

ios - 重命名项目后找不到共享内部框架

ios - 禁用带有 textFieldDidBeginEditing 的 UIButton 需要单击 UITextField 才能生效

ios - 无法打开使用 AFNetworking 的旧 iOS 项目

ios - 更改正在运行的动画的持续时间(速度)

swift - 不同的测试装配

ios - Swift:无法使用 Pod 文件中的库

objective-c - 如何在应用程序中的任何地方设置导航栏的图像