2017-02-23 81 views
0

我想解決的參數爲INSendPaymentIntent,使金額永遠不應小於零。構建失敗,在else塊中出現錯誤,說解決INSendPaymentIntent參數失敗

'/Users/xx/Documents/Appcelerator_Studio_Workspace/SiriTestApp/extensions/SiriTestApp/siritestapp/IntentHandler.swift:123:79: Cannot convert value of type 'NSDecimalNumber' to expected argument type 'INCurrencyAmount'. 

它期望一個INCurrencyAmount類型的對象。代碼中有什麼錯誤?

completion(INCurrencyAmountResolutionResult.success(with: currencyAmount)) 

感謝:

// Called when you need to resolve the currency amount to be transferred. 
    func resolveCurrencyAmount(forSendPayment intent: INSendPaymentIntent, with completion: @escaping (INCurrencyAmountResolutionResult) -> Void) { 

    // Resolve the currency amount. 
     if let currencyAmount = intent.currencyAmount, let amount = currencyAmount.amount{ 
      if amount.intValue <= 0 { 
       // The amount needs to be a positive value. 
       completion(INCurrencyAmountResolutionResult.unsupported()) 
      }else{ 
       completion(INCurrencyAmountResolutionResult.success(with: amount)) 
      } 
     } 

} 
+0

你的else塊應該在'if amount.intValue <= 0'檢查之後,而不是在外層如果let。 – dan

+0

嗨@dan我已更正了代碼謝謝。但仍有錯誤(粘貼在上面) –

回答

0

正確地需要的最後else塊被作爲一種INCurrencyAmount的通過。