无法使用“(_)”类型的参数列表调用 'perform'
Cannot invoke 'perform' with an argument list of type '(_)'
为什么直接针对他们的自述文件的这个 Square 示例不起作用?
let callbackURL = URL(string: "OdinMobile://")!
do {
let amount = try SCCMoney(amountCents: money, currencyCode: "USD")
let request : SCCAPIRequest =
try SCCAPIRequest(
callbackURL: callbackURL,
amount: amount,
userInfoString: userInfoString,
merchantID: nil,
notes: notes,
customerID: nil,
supportedTenderTypes: supportedTenderTypes,
clearsDefaultFees: clearsDefaultFees,
returnAutomaticallyAfterPayment: true
)
} catch let error as NSError {
print(error.localizedDescription)
}
do {
try SCCAPIConnection.perform(request)
} catch let error as NSError {
print(error.localizedDescription)
}
我收到一条 Cannot invoke 'perform' with an argument list of type '(_)'
和一条附加消息 Overloads for 'perform' exist with these partially matching parameter lists: (SCCAPIRequest), (Selector!)
。我希望 request
成为一个 SCCAPIRequest,为什么它不作为一个读取?是因为它在 do
块中吗?
do
关键字在其花括号内创建一个范围,如 if
或 for
循环,这意味着您创建的请求在第一个范围内并且在第一个范围内不可用第二。由于在这两种情况下,您都在做同样的事情并出现相同的错误,因此您只需将 perform
调用移动到同一范围内即可。
let callbackURL = URL(string: "OdinMobile://")!
do {
let amount = try SCCMoney(amountCents: money, currencyCode: "USD")
let request : SCCAPIRequest =
try SCCAPIRequest(
callbackURL: callbackURL,
amount: amount,
userInfoString: userInfoString,
merchantID: nil,
notes: notes,
customerID: nil,
supportedTenderTypes: supportedTenderTypes,
clearsDefaultFees: clearsDefaultFees,
returnAutomaticallyAfterPayment: true
)
try SCCAPIConnection.perform(request)
} catch let error as NSError {
print(error.localizedDescription)
}
为什么直接针对他们的自述文件的这个 Square 示例不起作用?
let callbackURL = URL(string: "OdinMobile://")!
do {
let amount = try SCCMoney(amountCents: money, currencyCode: "USD")
let request : SCCAPIRequest =
try SCCAPIRequest(
callbackURL: callbackURL,
amount: amount,
userInfoString: userInfoString,
merchantID: nil,
notes: notes,
customerID: nil,
supportedTenderTypes: supportedTenderTypes,
clearsDefaultFees: clearsDefaultFees,
returnAutomaticallyAfterPayment: true
)
} catch let error as NSError {
print(error.localizedDescription)
}
do {
try SCCAPIConnection.perform(request)
} catch let error as NSError {
print(error.localizedDescription)
}
我收到一条 Cannot invoke 'perform' with an argument list of type '(_)'
和一条附加消息 Overloads for 'perform' exist with these partially matching parameter lists: (SCCAPIRequest), (Selector!)
。我希望 request
成为一个 SCCAPIRequest,为什么它不作为一个读取?是因为它在 do
块中吗?
do
关键字在其花括号内创建一个范围,如 if
或 for
循环,这意味着您创建的请求在第一个范围内并且在第一个范围内不可用第二。由于在这两种情况下,您都在做同样的事情并出现相同的错误,因此您只需将 perform
调用移动到同一范围内即可。
let callbackURL = URL(string: "OdinMobile://")!
do {
let amount = try SCCMoney(amountCents: money, currencyCode: "USD")
let request : SCCAPIRequest =
try SCCAPIRequest(
callbackURL: callbackURL,
amount: amount,
userInfoString: userInfoString,
merchantID: nil,
notes: notes,
customerID: nil,
supportedTenderTypes: supportedTenderTypes,
clearsDefaultFees: clearsDefaultFees,
returnAutomaticallyAfterPayment: true
)
try SCCAPIConnection.perform(request)
} catch let error as NSError {
print(error.localizedDescription)
}