[英]Type MyViewController does not conform to protocol 'STPPaymentContextDelegate'
I'm creating an extension on my class to conform to the protocol 'STPPaymentContextDelegate'. 我正在我的类上创建一个扩展,以符合协议'STPPaymentContextDelegate'。 For some reason, the compiler complains, even though I have all the methods within the extension all declared properly like so.
由于某种原因,编译器抱怨,即使我在扩展中的所有方法都如此正确地声明。
extension PaymentPopupViewController: STPPaymentContextDelegate {
func paymentContext(_ paymentContext: STPPaymentContext, didFailToLoadWithError error: Error) {
self.delegate?.paymentPopupViewController(controller: self, didFinishPerhapsWithError: error as NSError?)
}
func paymentContextDidChange(_ paymentContext: STPPaymentContext) {
if paymentContext.loading {
self.indicatorView.startAnimating()
} else {
self.indicatorView.stopAnimating()
if paymentContext.selectedPaymentMethod == nil {
self.presentPaymentMehtodsViewController()
}
}
self.indicatorView.isHidden = !paymentContext.loading
self.paymentMethodLabel.isHidden = paymentContext.loading
self.changePaymentMethodButton.isEnabled = !paymentContext.loading
self.payButton.isEnabled = !paymentContext.loading && paymentContext.selectedPaymentMethod != nil
self.paymentMethodLabel.text = paymentContext.selectedPaymentMethod?.label
}
func paymentContext(_ paymentContext: STPPaymentContext, didCreatePaymentResult paymentResult: STPPaymentResult, completion: STPErrorBlock) {
fatalError("Method isn't implemented because our backend makes a charge, not the app.")
}
func paymentContext(_ paymentContext: STPPaymentContext, didFinishWith status: STPPaymentStatus, error: Error?) {
if status == .userCancellation {
return
}
self.delegate?.paymentPopupViewController(controller: self, didFinishPerhapsWithError: error as NSError?)
}
Here are the delegate methods as stated by the protocol: 以下是协议规定的委托方法:
@protocol STPPaymentContextDelegate <NSObject>
- (void)paymentContext:(STPPaymentContext *)paymentContext didFailToLoadWithError:(NSError *)error;
- (void)paymentContextDidChange:(STPPaymentContext *)paymentContext;
- (void)paymentContext:(STPPaymentContext *)paymentContext
didCreatePaymentResult:(STPPaymentResult *)paymentResult
completion:(STPErrorBlock)completion;
- (void)paymentContext:(STPPaymentContext *)paymentContext
didFinishWithStatus:(STPPaymentStatus)status
error:(nullable NSError *)error;
How do I go about resolving this issue? 我该如何解决这个问题?
You have some mistakes in your implementations. 您的实施中存在一些错误。
Replace this 替换它
func paymentContext(_ paymentContext: STPPaymentContext, didFailToLoadWithError error: Error)
With 同
func paymentContext(_ paymentContext: STPPaymentContext, didFailToLoadWithError error: NSError)
And replace this 并取而代之
func paymentContext(_ paymentContext: STPPaymentContext, didFinishWith status: STPPaymentStatus, error: Error?)
With 同
func paymentContext(_ paymentContext: STPPaymentContext, didFinishWithStatus status: STPPaymentStatus, error: NSError?)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.