As the error says, you have to build an Array . Try:
if let credentials = (credentialStorage?.credentialsForProtectionSpace(protectionSpace)?.values).map(Array.init) {
In Swift1.2, values on Dictionary<Key, Value> returns LazyForwardCollection<MapCollectionView<[Key : Value], Value>> type that has a .array property that returns Array<Value> .
In Swift2, values on Dictionary<Key, Value> returns LazyMapCollection<[Key : Value], Value> , and the .array property .array abandoned because we can build an Array using Array(dict.values) .
In this case, since credentialStorage?.credentialsForProtectionSpace(protectionSpace)?.values ends with the Optional type, we cannot just Array(credentialStorage?.cre...) . Instead, if you want Array , we should use map() on Optional .
But in this particular case, you can use credentialStorage?.credentialsForProtectionSpace(protectionSpace)?.values as it is.
Try:
if let credentials = credentialStorage?.credentialsForProtectionSpace(protectionSpace)?.values { for credential in credentials {
This works because the LazyMapCollection matches the SequenceType .
source share