Take the 2-minute tour ×

The below code behaves as expected however the compiler keeps telling me this: warning: 'StatusViewController' may not respond to '-beginLoadingThreadData'

How do I get rid of that warning and most important why xcode believes that is the case?

here is my code:

[self beginLoadingThreadData]; // called in the loadDidView block

- (void)beginLoadingThreadData
    [NSThread detachNewThreadSelector:@selector(loadThreadData) toTarget:self withObject:nil];

- (void)loadThreadData
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    [NSThread sleepForTimeInterval:2];
    [self performSelectorOnMainThread:@selector(finishedLoadingThreadData) withObject:nil waitUntilDone:NO];
    [pool release];

- (void)finishedLoadingThreadData
    [[BusinessLogic instance] startTracking:self];
share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

Declare that method before you use it. I'm assuming it's a private method, in which case you would add a class extension at the top of the implementation file:

@interface MyClass ()
- (void) beginLoadingThreadData;

If it's a public method, make sure you've declared the method in your header and #imported the header at the top of the implementation file.

share|improve this answer
I must have checked 3 times and I saw the declaration... more than an app I need an eye doctor - thanks Peter! –  amok Sep 24 '09 at 21:13
add comment

You have to either move the definition of loadingThreadData before the definition of viewDidLoad, or define it in the header file for StatusViewController, for example by inserting -(void)beginLoadingThreadData; before the @end in the header file (probably StatusViewController.h).

The reason is that if you don't do this, when the compiler reached your viewDidLoad method, and sees the call to beginLoadingThreadData, it has not yet seen the definition of beginLoadingThreadData, and hasn't been assured (by seeing a declaration with the method signature in the header file) that such a definition exists. Therefore it warns you that the method you're trying to call might not exist.

share|improve this answer
add comment

Your Answer


