转义闭包只能通过值明确捕获inout参数

时间:2017-07-06 09:14:27

标签: ios swift3 swift2.3

我将我的项目从swift 2.3更新到swift 3,我得到了“转义闭包只能通过值明确捕获inout参数” 在第一次递归调用它运行时没有错误,第二次我得到了这个错误。这是我的代码:

 static func downloadFiles(_ files:  inout [Links]) 
{
if files.count <= 0 {
            return
        }

        let link = files[0]
        print(link.path)

       let sss = FCFileManager.pathForDocumentsDirectory(withPath: link.localPath)
        FCFileManager.createDirectories(forPath: FCFileManager.pathForDocumentsDirectory(withPath: "\(Const.LAWYERAGENDA)/\(link.type)"))
        if FCFileManager.existsItem(atPath: sss) {
       files.remove(at: 0)
            downloadFiles(&files)
            return
        }
        print(link.path)
        let rr = URLRequest(url: URL(string: link.path)!)
        URLSession.shared.dataTask(with: rr, completionHandler: { (data, response, error) in
                    if error != nil {
                        print(error.debugDescription)
                    } else {

                        do {
                            FCFileManager.createFile(atPath: sss, overwrite: true)
                            try FCFileManager.writeFile(atPath: sss, content: data as NSObject!, error: ())

                        } catch let err as NSError {
                            print(err.description)
                        }
                    }


            files.remove(at: 0) /escaping closures...
            downloadFiles(&files) /escaping closures...
        }).resume()
    }

0 个答案:

没有答案