I know it is a common problem, I googled a lot and seems get no luck to solve my problem.
I have a @interface TestViewController:UIViewController
and in its implementation file I have a method defined:
-(void)method1 {
do something;
[self method1];//here I need to call the method itself if a statement is true and this line is where the warning TestViewController may not respond to'method1' I got
}
-(void)method2{
[self method1] //But there is no problem with this line
}
Can anyone help me?
Thanks in advance!
Your method declarations are missing in the header.
Just add
to your TestViewController.h file
Update:
The reason why you don’t get a warning about the second call (
[self method1]within method2) is, that the compiler already knows about method1 at that point. (because the implementation occurs before method2)