2017-08-12 1 views
1

J'essaie d'effectuer une segue après le téléchargement. J'ai d'abord essayé BlockOperation, mais j'ai échoué.Comment effectuer un segue après 5 fichiers à télécharger demande terminée dans swift3

Voici mon code.

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) } 

Je veux d'abord définir un tableau de [BlockOperation]. Puis, en essayant d'ajouter Alamofire.download dans ce tableau, mais échoué.

Je ne sais pas quelle partie a eu tort, peut-être que chaque bloc a besoin d'un nom différent?

S'il vous plaît aidez-moi.

Répondre