views:

60

answers:

1

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 header...

I should add that the call works, just want to get rid of the warnings.

Thanks

+4  A: 
[[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]];
V1ru8