Reputation: 14543
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
...
And in my interface I have:
@property (nonatomic, copy) void (^completionStatus)(PKPaymentAuthorizationStatus);
@property (nonatomic, copy) void (^completionResult)(PKPaymentAuthorizationResult *);
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?
Upvotes: 2
Views: 1856
Reputation: 4166
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.
Upvotes: 5
Reputation: 2587
You can do this as well I believe.
@property (nonatomic, copy) void (^completionResult)(PKPaymentAuthorizationResult *) API_AVAILABLE(ios(11.0));
Upvotes: 3