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