How to solve “undeclared selector 'forwardGeocoderDidFail:withErrorMessage” warning?
-
23-12-2019 - |
Question
How do I solve this warning?
The warning is "undeclared selector 'forwardGeocoderDidFail:withErrorMessage:'". Why am I getting this warning, and how can I solve it?
This is my code:
if (!handeledByBlocks && self.delegate) {
if (!parseError && parser.statusCode == G_GEO_SUCCESS)
{
[self.delegate forwardGeocodingDidSucceed:self withResults:parser.results];
}
else if ([self.delegate respondsToSelector:@selector(forwardGeocoderDidFail:withErrorMessage:)])
{
[self.delegate forwardGeocodingDidFail:self withErrorCode:parser.statusCode andErrorMessage:[parseError localizedDescription]];
}
}
Solution
Replace
[self.delegate respondsToSelector:@selector(forwardGeocoderDidFail:withErrorMessage:)]
with
[self.delegate respondsToSelector:@selector(forwardGeocodingDidFail:withErrorCode:andErrorMessage:)]
OTHER TIPS
Whatever you're setting as the delegate does not have a public method called: forwardGeocoderDidFail:withErrorMessage:
That's what's causing the warning that you want to fix.
In the line below, you're calling a method with a different signature.
forwardGeocoderDidFail: withErrorCode: andErrorMessage:
Make sure whatever object is your delegate actually implements the correct method, and that respondsToSelector
actually checks the one you want.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow