刚刚更新到swift 2.0,并且出现错误。'array'is unavailable:Please construct an Array from your lazy sequence:Array(...)error
我得到的错误是:'数组' 不可用:请从你的懒惰序列构建一个数组:数组(...)
我的代码是:
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!)")
}
}
}
会任何人都知道如何将这行代码转换为Swift 2.0更新?
if let credentials = credentialStorage.credentialsForProtectionSpace(protectionSpace)?.values.array
什么版本的Xcode的? – pixyzehn
它在我的操场上工作。 – pixyzehn
@pixyzehn这是版本7测试版6个 – Bills