无法在 xcode 8 beta 6 上编译 AWS CustomIdentityProvider
Unable to compile AWS CustomIdentityProvider on xcode 8 beta 6
我在 ios 应用程序中使用 Amazon Cognito 和 Facebook 登录。在 beta 5 之前,此代码 有效:
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'
这是 swift 版本。 3.
转换为 NSDictionary 而不是 Swift 字典:
return AWSTask(result: tokens! as NSDictionary)
我在 ios 应用程序中使用 Amazon Cognito 和 Facebook 登录。在 beta 5 之前,此代码
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'
这是 swift 版本。 3.
转换为 NSDictionary 而不是 Swift 字典:
return AWSTask(result: tokens! as NSDictionary)