Unable to compile AWS CustomIdentityProvider on xcode 8 beta 6

喜欢而已 提交于 2019-12-07 06:31:57

问题


I am using Amazon Cognito and Facebook login in an ios app. Up until beta 5 this code from this SO thread worked:

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
    }
}

In beta 6 I get this compile error:

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

When I change the line to

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

I get the error

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

This is swift ver. 3.


回答1:


Cast to NSDictionary instead of a Swift Dictionary:

return AWSTask(result: tokens! as NSDictionary)


来源:https://stackoverflow.com/questions/39045869/unable-to-compile-aws-customidentityprovider-on-xcode-8-beta-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!