0

I have this in my .pch file:

#import "UIViewController+Loader.h"

The implementation for the category looks like this:

static char kUIViewControllerBaseViewKey;

@implementation UIViewController (Loader)

- (void)setLoader:(LoaderView *)loaderView {
    objc_setAssociatedObject(self, &kUIViewControllerBaseViewKey, loaderView, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (LoaderView *)loader {
    LoaderView *loaderView = (LoaderView *)objc_getAssociatedObject(self, &kUIViewControllerBaseViewKey);
    if (!loaderView) {
        loaderView = [[LoaderView alloc] initWithView:self.view];
        [self.view addSubview:loaderView];
        [self setLoader:loaderView];
    }
    return loaderView;
}

@end

The problem is that in any view controller when I do this:

[self.loaderView doSomething];

Xcode shows this error: Property 'loaderView' not found on object of type MyViewController

HOWEVER, the project compiles fine and the doSomething: method on loaderView works fine. How can I get Xcode to stop showing these errors?

soleil
  • 12,133
  • 33
  • 112
  • 183

1 Answers1

0

After much head scratching, I found a build setting called "Increase Sharing of Precompiled Headers". Changing this to YES made the problem go away. After reading the description of what this does, I still don't understand why this fixes the problem. But it's fixed.

soleil
  • 12,133
  • 33
  • 112
  • 183