문제

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>'
도움이 되었습니까?

해결책

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

AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top