self method not found
I have a view controller class with the following code:
-(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];
}
the statement
[self addNewButtonWithTitle:title];
generates a warning: method addNewButtonWithTitle not found.
Con't figure it out.
Thanks
You have 3 options to get rid of the warning:
- Declare the method in the @
interface
block.
If you do not want to expose the method in your interface:
- Declare the method in a class extension.
- Implement the method above the first call to it.
Have you added method in .h file ?
You need to declare that method in your header file and if not then the method definition should be above the place where you call it.
So in your header file of whereever you have written @interface add the line :
- (void)addNewButtonWithTitle:(NSString *)title
精彩评论