I update my project from swift 2.3 to swift 3 and I got "escaping closures can only capture inout parameters explicitly by value" In first recursion call it's run with no error and the second I got this error.this is my code :
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()
}