【问题标题】:Unable to compile AWS CustomIdentityProvider on xcode 8 beta 6无法在 xcode 8 beta 6 上编译 AWS CustomIdentityProvider
【发布时间】:2016-12-27 00:25:40
【问题描述】:

我在 ios 应用程序中使用 Amazon Cognito 和 Facebook 登录。在 beta 5 之前,此代码 from this SO thread 有效:

class CustomIdentityProvider: NSObject, AWSIdentityProviderManager {
    var tokens: [NSString: NSString]?

    init(tokens: [NSString: NSString]) {
        self.tokens = tokens
    }

    @objc func logins() -> AWSTask<NSDictionary> {
        return AWSTask(result: tokens) // Compile error in beta 6
    }
}

在 beta 6 中我得到这个编译错误:

Cannot convert value of type '[NSString:NSString]?' to expected argument type '_?'

当我把线改为

return AWSTask(result: tokens! as [AnyObject: AnyObject])

我得到了错误

Type 'AnyObject' does not conform to protocol 'Hashable'

这是快速版本。 3.

【问题讨论】:

    标签: ios swift amazon-web-services beta xcode8-beta6


    【解决方案1】:

    转换为 NSDictionary 而不是 Swift 字典:

    return AWSTask(result: tokens! as NSDictionary)
    

    【讨论】:

    • 谢谢。 :-) 这很明显。
    猜你喜欢
    • 2016-12-29
    • 1970-01-01
    • 1970-01-01
    • 2014-08-10
    • 2014-11-03
    • 2016-12-27
    • 1970-01-01
    • 1970-01-01
    • 2016-12-29
    相关资源
    最近更新 更多