Reputation: 1229
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>'
Upvotes: 2
Views: 913
Reputation: 3211
You need to cast it to your AppDelegate
's type -
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
Upvotes: 3