Pregunta

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>'
¿Fue útil?

Solución

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

AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top