小编Bil*_*lls的帖子

'array'不可用:请从你的懒惰序列构造一个数组:Array(...)错误

刚刚更新到swift 2.0,我遇到了错误.

我得到的错误是:'array'不可用:请从你的懒惰序列构造一个数组:Array(...)

我的代码是:

            if let credentialStorage = session.configuration.URLCredentialStorage {
            let protectionSpace = NSURLProtectionSpace(
                host: URL!.host!,
                port: URL!.port?.integerValue ?? 0,
                `protocol`: URL!.scheme,
                realm: URL!.host!,
                authenticationMethod: NSURLAuthenticationMethodHTTPBasic
            )
// ERROR------------------------------------------------?
            if let credentials = credentialStorage.credentialsForProtectionSpace(protectionSpace)?.values.array {
// ERROR------------------------------------------------?
                for credential: NSURLCredential in (credentials) {
                    components.append("-u \(credential.user!):\(credential.password!)")
                }
            } else {
                if let credential = delegate.credential {
                    components.append("-u \(credential.user!):\(credential.password!)")
                }
            }
        }
Run Code Online (Sandbox Code Playgroud)

有谁知道如何转换这行代码来更新Swift 2.0?

if let credentials = credentialStorage.credentialsForProtectionSpace(protectionSpace)?.values.array

arrays swift alamofire swifty-json

5
推荐指数
1
解决办法
2574
查看次数

标签 统计

alamofire ×1

arrays ×1

swift ×1

swifty-json ×1