【发布时间】:2017-08-12 14:46:28
【问题描述】:
我正在尝试下载后执行 segue。 我先尝试了 BlockOperation,但失败了。
下面是我的代码。
let operationQ = OperationQueue()
let taskArray: [BlockOperation]
for index in 0..<songsList.count {
let eachSong = songsList[index]
let destination: DownloadRequest.DownloadFileDestination = { _, _ in
let documentsURL = NSHomeDirectory() + "/Documents/"
let fileURL = URL(fileURLWithPath: documentsURL.appending("song\(index).m4a"))
print("song\(index).m4a is downloading")
return (fileURL, [.removePreviousFile, .createIntermediateDirectories])
}
taskArray.append(BlockOperation(block: let task = {
Alamofire.download(eachSong, to: destination).response { _ in
// print(response.response)
}
}))
taskArray[4].completionBlock = { performSegue(withIdentifier: "NextVC", sender: self) }
我想先设置一个[BlockOperation]数组。
然后,尝试将 Alamofire.download 附加到此数组中,但失败了。
我不确定哪个部分出错了,也许每个块需要不同的名称?
请帮帮我。
【问题讨论】:
标签: ios swift segue grand-central-dispatch