相关疑难解决方法(0)

Swift 3 URLSession.shared()对成员'dataTask(with:completionHandler :)的错误引用错误(bug)

你好我有工作json解析swift2.2的代码,但当我用它为Swift 3.0给我错误

ViewController.swift:132:31:对成员'dataTask(with:completionHandler :)'的模糊引用

我的代码在这里

   let listUrlString =  "http://bla.com?batchSize=" + String(batchSize) + "&fromIndex=" + String(fromIndex)
    let myUrl = URL(string: listUrlString);
    let request = NSMutableURLRequest(url:myUrl!);
    request.httpMethod = "GET";

    let task = URLSession.shared().dataTask(with: request) {
        data, response, error in

        if error != nil {
            print(error!.localizedDescription)
            DispatchQueue.main.sync(execute: {
                AWLoader.hide()
            })

            return
        }

        do {

            let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSArray

            if let parseJSON = json {

                var items = self.categoryList

                items.append(contentsOf: parseJSON as! [String])

                if self.fromIndex < items.count { …
Run Code Online (Sandbox Code Playgroud)

json ios swift3

162
推荐指数
5
解决办法
10万
查看次数

标签 统计

ios ×1

json ×1

swift3 ×1