views:

89

answers:

2

I have a few methods for initialization of different stuff in my class implementation. However, when I invoke these methods by using [self 'methodName'], the Xcode compiler gives me a warning that I could not get rid of.

'className' may not respond to 'methodName'

For example,

warning: 'NextJackpotViewController' may not respond to -initActivityIndicator'

- (void)viewDidLoad {
    [self initActivityIndicator];
    [self addRefreshButton];
    [self updateUI];

    [super viewDidLoad];
}

Anything that could be done to get rid of this?

Cheerios, Rahul.

+3  A: 

Make sure the method is defined in your header file. In this case:

// NextJackpotViewController.h 
- (void)initActivityIndicator;
Matt Williamson
Or you can make sure it is defined before the method that calls it in the same file (higher up in your .m file).
Matt Williamson
+2  A: 

There are 3 ways to do this. The first is to just put the method declaration in your header file like Matt said.

The second is by creating Private Methods you can do this by putting the following code at the top of your controller

@interface NextJackportViewController (PrivateMethods)
- (void)initActivityIndicator;
@end

The third way is to define the method before you call it.

Conceited Code
Note that the word `PrivateMethods` isn't a keyword or anything special, you could just as easily replace it with `OtherStuff` (not saying you should)
cobbal