views:

55

answers:

3

When calling a method, i use

[self methodname];

The problem im having is, in xCode i get loads of yellow ! saying xxxappdelegate.app may not respond to methodname

Is there a better way to call methods?

Thanks

+2  A: 

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
macatomy
Thanks,Ill take a look at my .h file again :)
+2  A: 

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
Gary
Thanks for that, :)
A: 

Add methodname to the @interface for the class, xxxappdelegate in your example. Or just make sure the methodname implementation is before the place you call it in the file.

drawnonward
Thank You for your help :)