开发者

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 vie开发者_JS百科wDidLoad];
}

Anything that could be done to get rid of this?


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.


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

// NextJackpotViewController.h 
- (void)initActivityIndicator;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜