最新消息:20210917 已从crifan.com换到crifan.org

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

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

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
94 queries in 0.196 seconds, using 23.30MB memory