Ios 解析INSendPaymentIntent的参数失败
我正在尝试解析INSendPaymentIntent的参数,以便金额永远不应小于零。生成失败,else块中出现错误Ios 解析INSendPaymentIntent的参数失败,ios,swift,sirikit,Ios,Swift,Sirikit,我正在尝试解析INSendPaymentIntent的参数,以便金额永远不应小于零。生成失败,else块中出现错误 '/Users/xx/Documents/Appcelerator_Studio_Workspace/SiriTestApp/extensions/SiriTestApp/siritestapp/IntentHandler.swift:123:79: Cannot convert value of type 'NSDecimalNumber' to expected argumen
'/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'.
它需要IncirencyAmount类型的对象。代码中有什么错误
// 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 ))
}
}
}
//需要解析要转账的货币金额时调用。
func resolveCurrencyAmount(对于SendPaymentIntent:INSendPaymentIntent,带完成项:@escaping(IncirenceYaMountResolutionResult)->Void){
//解析货币金额。
如果let currencyAmount=intent.currencyAmount,则let amount=currencyAmount.amount{
如果amount.intValuea正确,则需要将最后一个else块作为incurencyamount类型传递:
completion(INCurrencyAmountResolutionResult.success(with: currencyAmount ))
谢谢。您的else块应该在if amount.intValue Hi@dan后面,我已经更正了代码,谢谢。但是仍然有错误(粘贴在上面)