Reputation: 497
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?
Upvotes: 5
Views: 28509
Reputation: 4345
If the .h file has the method declared there can be some issue related to xcodes inability to index to solve this go to preferences and delete archives and other stored data.
Upvotes: 0
Reputation: 11
There is something called compiling order. When you call method foo
it is not defined yet, however when you call method blah
it is defined just in the upper line.
Much more specific:
cout << a;
string a = "hello";
When you do that you will get an error undefined variable "a". What you should do is:
string a = "hello";
cout << a;
Upvotes: 1
Reputation: 53659
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.
Upvotes: 0
Reputation: 5732
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
Upvotes: 4
Reputation: 18122
If you get that warning, that means either:
Upvotes: 5