@interface中的Objective-C特定iOS版本 [英] Objective-c specific iOS version in @interface
本文介绍了@interface中的Objective-C特定iOS版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试实现Apple Pay,我尝试实现2种方法,一种用于iOS10,一种用于iOS11 +,
I am trying to implement Apple Pay, and I try to implement 2 methods one for iOS10 and one for iOS11+,
所以在我的实现中,我有:
So in my implementation I have:
-(void) paymentAuthorizationViewController
(PKPaymentAuthorizationViewController *)controller
didAuthorizePayment:(PKPayment *)payment
handler:(void (^)(PKPaymentAuthorizationResult * _Nonnull))completion API_AVAILABLE(ios(11.0))
{
self.completionResult = completion
...
- (void) paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
didAuthorizePayment:(PKPayment *)payment
completion:(void (^)(PKPaymentAuthorizationStatus))completion
{
self.completionStatus = completion
...
在我的界面中,我有:
@property (nonatomic, copy) void (^completionStatus)(PKPaymentAuthorizationStatus);
@property (nonatomic, copy) void (^completionResult)(PKPaymentAuthorizationResult *);
我遇到的问题是XCode在界面中给我以下警告:
The issue I have is XCode give me the following warning in the interface:
'PKPaymentAuthorizationResult' is only available on iOS 11.0 or newer
这是实现版本特定代码的正确方法吗?我可以在界面中指定特定于版本的代码吗?
Is it a correct way to implement version specific code? Can I specify version specific code in interfaces?
推荐答案
要使界面中的警告静音,您可以尝试添加API_AVAILABLE宏,如下所示: API_AVAILABLE(ios(11.0))
声明的结尾.
To silent the warning in the interface you can try to add the API_AVAILABLE macros like this: API_AVAILABLE(ios(11.0))
at the end of the declaration.
这篇关于@interface中的Objective-C特定iOS版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文