Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling Method in xCode

When calling a method, I use

[self methodname];

The problem I'm having is, in xCode I get loads of warnings! It's saying "*xxxappdelegate.app may not respond to methodname*".

Is there a better way to call methods?

like image 961
user370507 Avatar asked Jun 21 '10 04:06

user370507


2 Answers

If you get that warning, that means either:

  • That method does not exist in your class
  • If you are calling that method on a different class (not self) then you have not imported the headers for that class
like image 57
indragie Avatar answered Oct 19 '22 01:10

indragie


These warnings just mean that the compiler does not know if the class in question has the method you are calling. Make sure the method you're calling is defined above the place in the .m file you are using it in, or declare the method at the top of the file.

@implemention A

-(void)blah
{
    [self foo]; // warning!
}

-(void)foo
{
    [self blah]; // no warning
}

@end
like image 40
Gary Avatar answered Oct 19 '22 02:10

Gary