为什么Xcode中显示appdelegate.h文件警告当使用AVAudioPlayer代理协议?
-
19-09-2019 - |
题
// --------- MyAppDelegate.h
@interface MyAppDelegate : NSObject <UIApplicationDelegate, AVAudioPlayerDelegate> {
// ---在某些其他.m文件,试图接取装置凭证驻留在MyAppDelegate ----------
MyAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
//结果 //警告:类型的“id”不符合“AVAudioPlayerDelegate”协议
解决方案
这是因为一个类型不匹配的: - 该UIApplication.delegate属性返回id类型的实例 - 您正在尝试这种情况下铸成MyAppDelegate它实现了UIApplicationDelegate和AVAudioPlayerDelegate协议。 - 正如委托属性返回类型不匹配的appDelegate类型,您看到这些警告
。不隶属于 StackOverflow