我宣布,我的应用程序的委托符合协议多协议
<UIApplicationDelegate, SKPaymentTransactionObserver>
(即应用程序委托接口)。
编译器告诉我在很多地方在我的代码是:
warning: type 'id <UIApplicationDelegate>' does not conform to the 'SKPaymentTransactionObserver' protocol
这是怎么回事?
我宣布,我的应用程序的委托符合协议多协议
<UIApplicationDelegate, SKPaymentTransactionObserver>
(即应用程序委托接口)。
编译器告诉我在很多地方在我的代码是:
warning: type 'id <UIApplicationDelegate>' does not conform to the 'SKPaymentTransactionObserver' protocol
这是怎么回事?
你ApplicationDelegate似乎缺少一些必要的代表,例如:
- (void)applicationWillResignActive:(UIApplication *)application
检查什么委托方法SKPaymentTransactionObserver
需要,并将它们添加到您的AppDelegate.m
您可能正在做类似[[SKPaymentQueue defaultQueue] addTransactionObserver:[[UIApplication sharedApplication] delegate]]
。由于-[UIApplication delegate]
被声明为返回id<UIApplicationDelegate>
,编译器无法知道返回的对象是否会实现SKPaymentTransactionObserver协议。尝试将代理分配给静态类型为您的代理类的变量,并将传递给您尝试调用的方法,编译器应该很高兴。
你是否声明过你的委托符合类声明和变量声明中的两个协议(或者你访问变量)? – 2011-01-27 02:45:01
@Bavarious:只在应用程序委托界面中。 – SK9 2011-01-27 02:49:11
发布添加事务观察者的代码。 – 2011-01-27 03:05:17