最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[已解决]swift出错:contains is unavailable call the contains() method on the sequence

iOS crifan 1505浏览 0评论

代码:

class DownloadDelegate: NSObject, NSURLSessionDownloadDelegate {

    var downloads: [Int: TCBlobDownload] = [:]

    let acceptableStatusCodes: Range<Int> = 200299

    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

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
84 queries in 1.410 seconds, using 22.05MB memory