0
私はクラス 'STPPaymentContextDelegate'に準拠するようにクラスに拡張機能を作成しています。何らかの理由で、コンパイラは、エクステンション内のすべてのメソッドがすべて正しく宣言されているにもかかわらず、不平を言っています。ここでタイプMyViewControllerがプロトコル 'STPPaymentContextDelegate'に準拠していません
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?)
}
プロトコルで述べたように、デリゲートメソッドです:
@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;
は、どのように私はこの問題の解決については行くのですか?
取得置き換えますNSErrorからエラー –
@FaisalSyedに変更したい2つの "fix-it"エラーエラーをNSErrorに変更せずに 'didFinishWith status'を' didFinishWithStatus status'に変更するのはどうですか? –
私はそれを試してみましょう –