Method not found in protocol: Objective C
I have this in my view controller:
[[[UIApplication sharedApplication] delegate] sendMessageAsSingleObject:[sender currentTitle]];
Which gives me this warning:
warning: '-sendMessageAsSingleObject:' not found in protocol(s)
But in my AppDelegate i have the method declared in the head开发者_JAVA百科er...
I should add that the call works, just want to get rid of the warnings.
Thanks
[[UIApplication sharedApplication] delegate]
Returns an object that implements the UIApplicationDelegate
protocol. This protocol doesn't have the method sendMessageAsSingleObject
. So your compiler doesn't know that this method is actually there. You need to cast the delegate first to the specific class of your application delegate.
MyAppDelegate *appDelegate = (MyAppDelegate*)[[UIApplication sharedApplication] delegate];
[appDelegate sendMessageAsSingleObject:[sender currentTitle]];
精彩评论