This is a very interesting error message, you may want to look at the order of the method you are calling, and the code that causes the warning message.
-(void) aMainMethod{
[self testMethod] //call the method, warning occurs here
....
}
//here's the method you are calling
-(void) testMethod{
NSLog(@"test");
}
If your method is at somewhere after the code you call it (if it’s like above), move it so that it’s before the code (like the code below), and the warning should go away. Even with the warning, you should still be able to compile and run without any problem.
//here's the method you are calling
-(void) testMethod{
NSLog(@"test");
}
-(void) aMainMethod{
[self testMethod] //no warning
....
}
Here’s an article about this with more details.
Hello!
Very Interesting post! Thank you for such interesting resource!
PS: Sorry for my bad english, I’v just started to learn this language
See you!
Your, Raiul Baztepo
Glad I can help ^__^
Cheers
Emily
Thanks a lot! Really helpful, I finally got rid of those silly warnings
If you would have declared the function in the header of the file (the .h file) then it would not matter where the function body exists.
Doing that will fix the errors as well. (Also the programming standard to declaring functions in C and Objective-C).
Well, that would make your interface unnecessarily bloated. You wouldn’t want to add internal methods to your interface.
Thanks, this helped.
FWIW, the problem appears to exist at the file level as well: class #0 in the file order calling a ‘-method’ from class #1 in the file order caused this problem for me. Reordering the files fixed it.
thank you!
my third day in objectiveC.
its annoying structure and too big file size.
they need actionscript for iphone. its better 1million times.
[...] http://mosisa.wordpress.com/2009/02/17/objective-c-warning-class-may-not-respond-to-method/ en http://stackoverflow.com/questions/1064082/myobject-may-not-respond-to-message-foo-noob-objective-c-question [...]