代码:
class DownloadDelegate: NSObject, NSURLSessionDownloadDelegate {
var downloads: [Int: TCBlobDownload] = [:]
let acceptableStatusCodes: Range<Int> = 200…299
func validateResponse(response: NSHTTPURLResponse) -> Bool {
return contains(self.acceptableStatusCodes, response.statusCode)
}
出错:
/Users/crifan/dev/dev_root/daryun/JianDao/iOS-Client/JianDao/TCBlobDownloadManager.swift:153:16: ‘contains’ is unavailable: call the ‘contains()’ method on the sequence
搜:’contains’ is unavailable: call the ‘contains()’ method on the sequence
swift2 – Can’t use method "contains" in Swift 2 – Stack Overflow
改为:
func validateResponse(response: NSHTTPURLResponse) -> Bool {
//return contains(self.acceptableStatusCodes, response.statusCode)
return self.acceptableStatusCodes.contains(response.statusCode)
}
即可。
转载请注明:在路上 » [已解决]swift出错:contains is unavailable call the contains() method on the sequence