【发布时间】:2017-11-04 23:50:18
【问题描述】:
我正在使用 AWS Mobile Hub 为我用 Swift 编写的 iOS 应用程序实现登录。直到本周,它运行良好,但更新到 Xcode 9.1 导致发生了几个构建错误。我还有 2 个错误。两者都涉及专门对协议的调用; 'AWSSignInDelegate' 和 'AWSCognitoIdentityPasswordAuthentication'。
extension SignInVC: AWSSignInDelegate
{
func onLogin(signInProvider: AWSSignInProvider, result: Any?, error: Error?)
{
//Code
}
}
extension SignInVC: AWSCognitoIdentityPasswordAuthentication
{
func getDetails(_ authenticationInput: AWSCognitoIdentityPasswordAuthenticationInput, passwordAuthenticationCompletionSource: AWSTaskCompletionSource<AWSCognitoIdentityPasswordAuthenticationDetails>)
{
//Code
}
func didCompleteStepWithError(_ error: Error?)
{
//Code
}
}
错误:
类型“SignInVC”不符合协议“AWSSignInDelegate”
候选人的类型不匹配'(AWSSignInProvider, Any?, Error?) -> ()'
和
类型“SignInVC”不符合协议“AWSCognitoIdentityPasswordAuthentication”
候选人的类型不匹配'(Error?) -> ()'
我目前所拥有的: 错误仅发生在包含快速类型“错误”作为参数的方法中。上面的“getDetails”调用似乎不会像其他 2 种方法那样引发错误。
这里有一个类似的问题: Cannot conform to STPAddCardViewControllerDelegate since Xcode 8 GM on Swift 3
建议将@escaping 添加到完成块以修复类似的错误。我的问题不涉及完成块。所以我假设我错误地将 swift Error 类型作为参数处理,因为这两种方法在 objc 中的实现使用 NSError。
关于如何解决此问题的任何建议? 非常感谢!
【问题讨论】:
标签: ios swift xcode amazon-web-services