2017-08-12 3 views
1

ダウンロード後にsegueを実行しようとしています。 まずBlockOperationを試しましたが、失敗しました。5ファイルのダウンロード要求がswift3で完了した後にsegueを実行する方法

以下は私のコードです。

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を追加しようとしましたが、失敗しました。

どの部分が間違っているのか分かりません。おそらくそれぞれのブロックに別の名前が必要ですか?

私を助けてください。

答えて

関連する問題