Question

I'm using my AppDelegate to handle some audio files. I've made it an AVAudioPlayer delegate so I can use methods like audioPlayerDidFinishPlaying.

I've done it like this:

@interface AppDelegate : UIResponder <UIApplicationDelegate, AVAudioPlayerDelegate>

And then in any ViewController I access my AppDelegate in the following way:

AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];

Everything works fine but I'm getting the following warning:

Assigning to 'APPDelegate *__strong' from incompatible type 'id<UIApplicationDelegate>'
Was it helpful?

Solution

You need to cast it to your AppDelegate's type -

AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top