最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

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

iOS crifan 503浏览 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,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
62 queries in 0.341 seconds, using 18.82MB memory