找不到自我方法

sam*_*n01 1 iphone xcode objective-c ipad

我有一个视图控制器类,代码如下:

-(void) awakeFromNib{
    RootModel *rm = [RootModel sharedModel];
    for(NSString *title in rm.rLevels) {
        [self addNewButtonWithTitle:title];
    }
}

// add a new button with the given title to the bottom of the list
- (void)addNewButtonWithTitle:(NSString *)title
{
    // create a new button
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
}
Run Code Online (Sandbox Code Playgroud)

该声明

[self addNewButtonWithTitle:title];
Run Code Online (Sandbox Code Playgroud)

生成警告:找不到方法addNewButtonWithTitle.

不知道了.

谢谢

alb*_*amg 7

您有3个选项可以摆脱警告:

  • 在@ interfaceblock中声明方法.

如果您不想在界面中公开该方法:

  • 类扩展中声明方法.
  • 在第一次调用它时实现上面的方法.