首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AWS iOS Swift 3认知类型不符合协议

AWS iOS Swift 3认知类型不符合协议
EN

Stack Overflow用户
提问于 2017-01-04 12:38:37
回答 1查看 541关注 0票数 0

嗨,我在iOS中使用AWS,我遵循了aut的介绍。它说我必须从示例中导入用户池文件。我这样做了,但这给我带来了一个错误:

代码语言:javascript
复制
extension SignInViewController: AWSCognitoIdentityPasswordAuthentication {

    func getDetails(_ authenticationInput: AWSCognitoIdentityPasswordAuthenticationInput, passwordAuthenticationCompletionSource: AWSTaskCompletionSource<AnyObject>) {
        self.passwordAuthenticationCompletion = passwordAuthenticationCompletionSource
    }

    func didCompleteStepWithError(_ error: Error?) {
        if let error = error {
            DispatchQueue.main.async(execute: {
                UIAlertView(title: "ERROR",
                    message: error.localizedDescription,
                    delegate: nil,
                    cancelButtonTitle: "Ok").show()
            })
        }
    }
}

错误:

类型'SignInViewController‘不符合协议'AWSCognitoIdentityPasswordAuthentication’

另外:

协议要求函数'getDetails(_:passwordAuthenticationCompletionSource:)‘(类型为'(AWSCognitoIdentityPasswordAuthenticationInput,AWSTaskCompletionSource) -> Void';要添加存根吗?(AWSCognitoIdentityProvider.AWSCognitoIdentityPasswordAuthentication)

以及:

候选人具有非匹配类型'(AWSCognitoIdentityPasswordAuthenticationInput,AWSTaskCompletionSource) -> ()‘

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-01-04 13:25:11

根据文档,任何符合AWSCognitoIdentityPasswordAuthentication的类都应该实现:

代码语言:javascript
复制
– getPasswordAuthenticationDetails:passwordAuthenticationCompletionSource
– didCompletePasswordAuthenticationStepWithError

您没有实现它们,因此出现了错误。

编辑是的,您是对的,函数签名在Swift 3中更改了(参见这里)。

他们应该是这样:

代码语言:javascript
复制
func getDetails(_ authenticationInput: AWSCognitoIdentityPasswordAuthenticationInput, passwordAuthenticationCompletionSource: AWSTaskCompletionSource<AWSCognitoIdentityPasswordAuthenticationDetails>)
func didCompleteStepWithError(_ error: Error?)

看起来您的第一个功能的版本略有不同。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41464046

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档