刚刚更新到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