Search code examples
iosobjective-ctyphoon

Receiving undeclared selector for private property


I have this initializer in an assembly:

- (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]];
    }];
}

The last line, when injecting mapFromSearchInput I receive a warning

undeclared selector 'mapFromSearchInput'

I have both properties in the private extension of APBSearchWireframe

@interface APBSearchWireframe()

@property (nonatomic, readwrite, strong) id<APBSearchView> searchViewController;
@property (nonatomic, readwrite, strong) id<APBMapFromSearchInput> mapFromSearchInput;

@end

And mapWireframe conforms to several interfaces

- (id<APBMapWireframeInterface, APBMapFromSearchInput>)mapWireframe;

If i move the property definition from the private extension to the .h the warning dissappears.Why am I getting the error for the second injection but no for the first one? I have all imports done correctly, and the app works fine, but this warning is really annoying...

Thank you.


Solution

  • Have you ensured that:

    • You're using forward declarations in your .h files (ie @class Something) and #import them in the .m?

    If so and the error still occurs, then it seems the compiler is getting confused. You could:

    • Pre-declare the selector using sel_registerName
    • Suppress this particular warning

    Example:

    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wundeclared-selector"
    
    ... your code here ...
    
    #pragma clang diagnostic pop