Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode warning: "May not respond to"

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?

like image 620
Rahul Jiresal Avatar asked Jun 26 '26 00:06

Rahul Jiresal


1 Answers

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.

like image 131
Conceited Code Avatar answered Jun 27 '26 20:06

Conceited Code



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!